私のカテゴリのpostsループにカスタムデータを表示する必要があります。私は自分の投稿テンプレートに特別なdivを作成したいと思っています。この投稿のループにこのdivのデータを表示したいのです。誰でも助けてくれますか?ありがとうWordpress postsループでカスタムデータを表示する
<?php
if (have_posts()) :
query_posts('cat=7');
while (have_posts()) : the_post(); ?>
<div class = "item">
<div class="item_image"><?php the_post_thumbnail(); ?></div>
<div class = "item_title"><?php the_title(); ?></div>
<div class = "item_excerpt"><?php the_excerpt(10); ?></div>
<!-- here I want to display data from each post -->
<div class = "my_custom_data">custom data</div>
<a href = "<?php the_permalink(); ?>" class = "item_link">Show more...</a>
</div>
<?php endwhile;
endif;
wp_reset_query();
?>
であれば、フィールドの名前例えばを取得する必要がありますか?どうしたの?ここでお勧めのhttps://codex.wordpress.org/Custom_Fieldsや独自のカスタムフィールドを作成することができます – omukiguy
@omukiguy ACFプラグインでカスタムフィールドを作成し、データを追加しました。今、私はサムネイル、タイトルなどを表示するsingle.phpテンプレートとpage-blog.php(たとえば)ループにこのデータを表示したいと思います。 –