Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$term = array_shift(get_the_terms($post->ID, 'foo')); | |
?> | |
<?php $tax_posts = get_posts('post_type=bar&posts_per_page=5&taxonomy=foo&term='.esc_html($term->slug)); if($tax_posts): ?> | |
<ul> | |
<?php foreach($tax_posts as $tax_post): ?> | |
<li><a href="<?php echo get_permalink($tax_post->ID); ?>"><?php echo esc_html($tax_post->post_title); ?></a></li> | |
<?php endforeach; ?> | |
</ul> | |
<?php endif; ?> | |
/*barがポストタイプ名でfooがタクソノミー名、&posts_per_page=は表示記事数*/ |
Screen shot
Note
Description | カスタム投稿の記事ページでその記事が持つタームと同じタームを持つ記事を羅列する |
---|---|
WordPress Ver. | 3.3.1 |
Via | WordPress › フォーラム » カスタム投稿のシングルページで同一ターム記事を一覧表示 |