###前提・実現したいこと
wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」をサイト上の投稿ページ内に表示したい
###発生している問題
カスタムフィールドは出力されているが、投稿文とは違うところに表示される。コードは公開されているものを使用しております。
###該当のソースコード
PHP
1<?php 2/** 3 * The Single-stores template 4 */ 5?> 6<?php get_header(); ?> 7 8<div id="single-content" class="clearfix"> 9 <article id="content-inner" class="clearfix"> 10 <div class="cont-wrap cf"> 11 12 <?php if ( have_posts() ) { 13 while ( have_posts() ) { 14 the_post(); 15 get_template_part( 'content', 'single' ); 16 } ?> 17ここから<?php 18//サイトURL 19 the_field('url'); ?><br />ここまでを追加 20 21<?php 22 chocolat_pagination(); 23 } else { 24 get_template_part( 'content', 'none' ); 25 } ?> 26</div><!-- /.single-cont --> 27 </article><!-- /content-inner --> 28 <?php chocolat_prevnext(); ?> 29</div><!-- /main-content --> 30<?php get_sidebar(); ?> 31<?php get_footer(); ?>
###試したこと
http://kotori-blog.com/wordpress/acf_output/
こちらのサイトのコードを使用しました。
###補足情報
WordPressバージョン 4.7
Advanced Custom Fields PROバージョン 5.3.8.1
カスタム投稿タイプの「Post Type Slug」は「stores」になります。
また、content-single.phpのコードを以下に表記します。
php
1<?php 2/** 3 * The Content-single template 4 */ 5?> 6<section id="<?php echo esc_attr( $post -> post_name ); ?>" <?php post_class( 'post-section clearfix' ); ?>> 7 <div class="section-top clearfix"> 8 <div class="entry-edit clearfix"> 9 <?php edit_post_link( __( 'Edit', 'chocolat' ), '<span class="post-edit">', '</span>' ); ?> 10 </div> 11 12 <?php chocolat_entry_dates(); ?> 13 14 <div class="entry-title"> 15 <h1 class="post-title"><?php the_title_attribute(); ?></h1> 16 </div> 17 </div><!-- /section-top --> 18 19 <div class="section-center clearfix"> 20 <?php chocolat_last_update(); ?> 21 <?php chocolat_entry_meta(); ?> 22 23 <?php if ( has_post_thumbnail() ) : ?> 24 <div class="entry-thumbnail thumbnail clearfix"> 25 <?php the_post_thumbnail( 'single-post-thumbnail' ); ?> 26 </div> 27 <?php endif; ?> 28 29 <div class="post-content clearfix"> 30 <div class="entry-content clearfix"> 31 <?php if ( is_attachment() && wp_attachment_is_image( $post->id ) ) { 32 $att_image = wp_get_attachment_image_src( $post->id, "full-size" ); 33 $att_excerpt = $post->post_excerpt; 34 35 echo '<div class="attachment-image">'."\n"; 36 echo '<img src="'.esc_url( $att_image[0] ).'" width="'.intval( $att_image[1] ).'" height="'.intval( $att_image[2] ).'" class="attachment-full-size" alt="'.esc_attr( $att_excerpt ).'" />'."\n"; 37 if ( ! empty( $att_excerpt ) ) { 38 echo '<p class="attachment-text">'.esc_attr( $att_excerpt ).'</p>'."\n"; 39 } 40 echo '</div>'."\n"; 41 } else { 42 the_content(); 43 } ?> 44 </div><!-- /entry-content --> 45 46 <?php if ( wp_link_pages( 'echo=0' ) ) : ?> 47 <div class="post-pagination clearfix"> 48 <?php wp_link_pages( array( 49 'before' => '<div class="post-numbers">', 50 'after' => '</div>', 51 'next_or_number' => 'number', 52 'pagelink' => '<span class="numbers">%</span>' 53 ) ); ?> 54 </div> 55 <?php endif; ?> 56 57 <?php chocolat_ad_widget_medium(); ?> 58 </div><!-- /post-content --> 59 </div><!-- /section-center --> 60 61 <div class="section-bottom clearfix"> 62 <div class="section-bottom-inner clearfix"> 63 </div> 64 </div><!-- /section-bottom --> 65</section><!-- /section --> 66 67<?php 68 if ( ! is_attachment() ) { 69 chocolat_related_post_list( 'related' ); 70 chocolat_new_post_list( 'new' ); 71 chocolat_ad_widget_medium_bottom( 'center' ); 72 comments_template(); 73 } 74?>
追加したカスタムフィールド
フィールド順序 1
フィールドラベル 基本情報
フィールド名
フィールドタイプ タブ
フィールド順序 2
フィールドラベル サイトURL
フィールド名 url
フィールドタイプ テキスト
と続きます。
別の制作者からデータのみ引き継いだものであり、その方は退職されておりどうしようもなくこちらに質問させていただきました。
ご教授宜しくお願い致します。
不足している情報などがあればご指摘ください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/29 15:50