お世話になります。
不動産サイトの運用をしており、
single.phpにプラグイン「Advance custom fields」で生成したフィールドを用いて物件の内容を投稿しております。
上記では30種類ほどのフィールドを用意しておりますが、
その投稿データの中から抜粋したフィールドとして生成したいです。
投稿をコピーする方法ではなく、1つのpostデータから2つの投稿ページを生成するような形で運用したいのですが、
良い方法はありますでしょうか?
Wordpressの基礎部分しか理解していないため、手段をご教示いただければと思います。
追記
具体的には
現在
single.phpにて、
<?php if(have_posts()): while(have_posts()): the_post(); ?> <!-- 物件情報1 --> <div class="detail01 btm030"> <h4><img src="<?php echo get_template_directory_uri(); ?>/images/arrowico-mid02.png" />物件空室 / 募集状況</h4> <table class="detail_table03"> <tr> <th>階数</th> <th>坪数</th> <th>賃料/円 (税別)</th> <th>共益費(税別)</th> <th>敷金</th> <th>礼金</th> <th>入居可能日</th> <th>間取図</th> </tr> <?php if(post_custom('rent') == '空き'): ?> <tr> <td><?php the_field("kai", $post->ID); ?></td> <td><?php the_field("tubo", $post->ID); ?>坪</td> <?php if(post_custom('yachin')): ?> <td><?php echo number_format(get_post_meta($post->ID,'yachin',true));?>円</td> <?php else : ?><td><span>応相談</span></td> <?php endif; ?> <?php if(post_custom('kyoeki')): ?> <td><?php echo number_format(get_post_meta($post->ID,'kyoeki',true));?>円</td> <?php else : ?><td>-</td> <?php endif; ?> <?php if(post_custom('sikien')): ?> <td><?php the_field("sikien", $post->ID); ?> <?php $array = array( "0" => "-" ); ?> </td> <?php else : ?><td>応相談</td> <?php endif; ?> <?php if(post_custom('reien')): ?> <td><?php the_field("reien", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> <?php if(post_custom('checkin')): ?> <td><?php the_field("checkin", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> <?php if(post_custom('space')): ?> <td><a href="javascript:w=window.open('<?php the_field("space", $post->ID); ?>','','scrollbars=yes,Width=470,Height=350');w.focus();">間取図</a></td> <?php else : ?><td>-</td> <?php endif; ?> </tr> <?php endif; ?> </table> <div><!-- datail01 --> <!-- //物件情報1 --> <!-- 物件情報2 --> <div class="detail02 btm050"> <table class="detail_table01"> <tr> <th>住所</th> <td><?php the_field("address", $post->ID); ?></td> </tr> <tr> <th>最寄駅</th> <td>【<?php the_field("station", $post->ID); ?>駅】 約<?php the_field("walk", $post->ID); ?>分 <?php if(post_custom('station2')): ?> 【<?php the_field("station2", $post->ID); ?>駅】 約<?php the_field("walk2", $post->ID); ?>分</td> </tr> <?php endif; ?> <?php if(post_custom('year')): ?> <tr> <th>竣工年月</th> <td><?php the_field("year", $post->ID); ?></td> </tr> <?php endif; ?> <?php if(post_custom('upkai')): ?> <tr> <th>地上階/地下階</th> <td><?php the_field("upkai", $post->ID); ?></td> </tr> <?php endif; ?> <?php if(post_custom('kozo')): ?> <tr> <th>構造</th> <td><?php the_field("kozo", $post->ID); ?></td> </tr> <?php endif; ?> <?php if(post_custom('text')): ?> <tr> <th><?php the_title(); ?>の特長</th> <td><?php the_field("text", $post->ID); ?></td> </tr> <?php endif; ?> </table> </div><!-- datail02 --> <!-- //物件情報2 --> <?php endwhile; else: ?> <p><?php echo "お探しの記事、ページは見つかりませんでした。"; ?></p> <?php endif; ?>
上記のような形で、カスタムフィールドで投稿した物件情報を出力しております。
上記と同じpostの情報を用いて印刷出力用に別のページを出力したいと思っております。
<?php if(have_posts()): while(have_posts()): the_post(); ?> <section class="title"> <p class="title_name"><?php the_title(); ?></p> </section> <section class="outline clearfix"> <h2>物件概要</h2> <dl class="add"><dt>所在地</dt><dd><?php if(post_custom('address')): ?><?php the_field("address", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>竣工</dt><dd><?php if(post_custom('year')): ?><?php the_field("year", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>構造</dt><dd><?php if(post_custom('kozo')): ?><?php the_field("kozo", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>規模</dt><dd><?php if(post_custom('upkai')): ?><?php the_field("upkai", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>時間制限</dt><dd><?php if(post_custom('time')): ?><?php the_field("time", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>トイレ</dt><dd>トイレの出力</dd></dl> <dl><dt>空調</dt><dd><?php if(post_custom('air')): ?><?php the_field("air", $post->ID); ?><?php endif; ?></dd></dl> <dl><dt>床</dt><dd><?php if(post_custom('time')): ?><?php the_field("oa", $post->ID); ?><?php endif; ?></dd></dl> </section> <section class="property"> <table class="type1"> <thead> <tr> <th scope="cols">階数</th> <th scope="cols">面積</th> <th scope="cols">敷金</th> <th scope="cols">賃料(税別)</th> <th scope="cols">共益費(税別)</th> <th scope="cols">礼金</th> <th scope="cols">契約期間</th> <th scope="cols">入居日</th> <th scope="cols">天井高</th> <th scope="cols">備考</th> </tr> </thead> <tbody> <!-- テナント情報 --> <?php if(post_custom('rent') == '空き'): ?> <tr> <?php if(post_custom('kai')): ?> <td><?php the_field("kai", $post->ID); ?></td> <?php else : ?><td><span>応相談</span></td> <?php endif; ?> <?php if(post_custom('kyoeki')): ?> <td><?php the_field("tubo", $post->ID); ?>坪</td> <td>12ヵ月</td> <?php else : ?><td><span>応相談</span></td> <?php endif; ?> <?php if(post_custom('yachin')): ?> <td><?php echo number_format(get_post_meta($post->ID,'yachin',true));?>円</td> <?php else : ?><td><span>応相談</span></td> <?php endif; ?> <?php if(post_custom('kyoeki')): ?> <td><?php echo number_format(get_post_meta($post->ID,'kyoeki',true));?>円</td> <?php else : ?><td>-</td> <?php endif; ?> <?php if(post_custom('reien')): ?> <td><?php the_field("reien", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> <td>2年間</td> <?php if(post_custom('checkin')): ?> <td><?php the_field("checkin", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> <?php if(post_custom('high')): ?> <td><?php the_field("high", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> <?php if(post_custom('biko')): ?> <td><?php the_field("biko", $post->ID); ?></td> <?php else : ?><td>応相談</td> <?php endif; ?> </tr> <?php endif; ?> <!-- //テナント情報 --> </tbody> </table> </section> <?php endwhile; else: ?> <p><?php echo "お探しの記事、ページは見つかりませんでした。"; ?></p> <?php endif; ?>
※ 投稿には設置されており、single.phpでは出力していないカスタムフィールドを、印刷用では利用していますのでご了承ください。
上記のような形で既存のsingle.phpで出力される情報とは別に、同様のpostのデータを用いて別ページを出力する方法はございますでしょうか。
よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー