アーカイブページ直にそれぞのカテゴリごとの最新記事1件づつ並べたページが作りたいので。
リンクはうまくいったのですが、サムネイル画像の出力がうまくいかず、ご教授いただきたいです。
よろしくお願いいたします。
カスタム投稿のAdvanced custom fieldsを使ってアップロードした画像です。
この状況ですと、カスタム投稿の同じ画像が羅列しカテゴリ別にならず困っています。
<?php
$taxonomy_name = 'eventcat';
$taxonomys = get_terms($taxonomy_name);
if(!is_wp_error($taxonomys) && count($taxonomys)):
foreach($taxonomys as $taxonomy):
$tax_posts = get_posts(array(
'posts_per_page'=> '1',
'post_type' => get_post_type(),
'taxonomy' => $taxonomy_name,
'term' => $taxonomy->slug ) );
if($tax_posts):
?>
<dl>
<dd>
<?php foreach($tax_posts as $tax_post): ?>
<h3><?php echo esc_html($taxonomy->name); ?></span></h3>
<p>最新<?php echo esc_html($tax_post->post_title); ?>号</p>
<a href="<?php echo get_permalink($tax_post->ID); ?>" class="icon03">詳細はこちら</a>
</dd>
<dt>
<li>
<a href="<?php echo get_permalink($tax_post->ID); ?>">
<img src="<?php the_field('ichiranimg'); ?>" width="100" height="145">
</a>
</li>
</dt>
<?php endforeach; ?>
</dl>
<?php
endif;
endforeach;
endif;
?>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/08 07:32
2018/03/08 07:33