在Wordpress博客中,我想将特定自定义分类法的术语描述放在每篇文章的页脚中。
这可能吗?我试过了
<?php term_description( $term_id, $taxonomy ) ?>
但运气不好。除非我用错了?使用时,不会显示任何内容。在Wordpress博客中,我想将特定自定义分类法的术语描述放在每篇文章的页脚中。
这可能吗?我试过了
<?php term_description( $term_id, $taxonomy ) ?>
但运气不好。除非我用错了?使用时,不会显示任何内容。听起来像是个愚蠢的问题,但你是在附和吗?
<?php echo term_description($term_id, $taxonomy); ?>
否则,您需要获取当前帖子的条款(其中my_term
是您的自定义分类法):$terms = wp_get_post_terms( $post->ID, \'my_term\' )
然后获取数组中第一个术语的描述:echo term_description($terms[0]->term_id, \'my_term\');
我没有测试过这个,但它应该会让你朝着正确的方向前进。下面是完整的代码(应该在single.php或loop.php中,或者在创建单个帖子的任何地方)。。。将其粘贴到循环中:
<?php $my_taxonomy = \'projects\'; // set this to whatever your custom taxonomy is called
$terms = wp_get_post_terms( $post->ID, $my_taxonomy ); // this gets all the terms attached to the post for your custom taxonomy
echo term_description($terms[0]->term_id, $my_taxonomy); // this displays the description for the first term in the $terms array ?>
希望有帮助,戴夫
请帮助了解自定义帖子类型“视频”的代码:If is single-video.php page { list custom-taxonomy of video. Example actors } Else { do nothing } 我尝试使用is\\u single、is\\u single、is\\u page\\u模板,但不可行。