我试图通过(特定)显示相关帖子\'post_tag\' 自定义帖子类型中的分类法。以下代码按自定义帖子类型显示所有帖子。
我的意思是我想通过\'Mp3\' 在单个帖子页面中自定义帖子类型。
$post_type = \'mp3\';
$tax = \'post_tag\';
$post_count = 5;
$counter = 0;
$tax_terms = get_terms($tax);
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args = array(
\'post_type\' => $post_type,
"$tax" => $tax_term->slug,
\'post_status\' => \'publish\',
\'orderby\' => \'rand\',
\'showposts\' => 5
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo \'<ul id="related-posts" class="item-list">\';
echo \'<h6>Related Posts</h6>\';
while ($my_query->have_posts() && $counter < $post_count) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php
$counter += 1;
endwhile;
echo \'</ul>\';
}
wp_reset_query();
}
}
所以我在这里寻求解决方案。。。