我正在慢慢发疯,试图弄明白这一点。。
我想按自定义分类法“mobile\\u phone”列出自定义帖子类型“mobile\\u review”,因为多个自定义帖子类型共享此分类法,所以我需要某种方式进行细分。
到目前为止,我有:
function get_terms_by_post_type($taxonomies,$args){
$args = array(
\'post_type\' => \'mobile_review\'
);
// The query for posts of type \'mobile_review\'
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
//get terms
//$mobs = wp_get_object_terms($post->ID,"mobile_phone");
$mobs = get_terms(\'mobile_phone\');
$count = count($terms);
if ( $count > 0 ){
echo "<ul>";
foreach ( $terms as $term ) {
echo "<li>" . $term->name . "</li>";
}
echo "</ul>";
}
endwhile;
// Reset Post Data
wp_reset_postdata();
}
我接近了吗?多年来,我一直在来回黑客攻击,但一无所获。任何帮助都会很好!提前谢谢。