我试图用一个计数器在作者页面中显示自定义分类,但似乎我不知道该怎么做.
我在function.php中有一个代码
add_action( 'pre_get_posts', function ( $q ) {
if( !is_admin() && $q->is_main_query() && $q->is_author() ) {
$q->set( 'posts_per_page', 100 );
$q->set( 'post_type', 'custom_feedback' );
}
});
Run Code Online (Sandbox Code Playgroud)
在我的作者页面中:
<div class="feedback-respond">
<h3 class="feedback-title">User Feedback </h3>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('No posts by this author.'); ?></p>
<?php endif; ?>
</div>
Run Code Online (Sandbox Code Playgroud)
该代码适用于所有作者配置文件,但我不知道如何使自定义分类法显示如下:
用户反馈
6积极反馈4负面反馈
所有反馈都在这里
所有反馈都在这里
所有反馈都在这里
顺便说一下,它是一个自定义的帖子类型(custom_feedback)和自定义分类法(feedback_taxonomy),有两个类别Positive和Negative.
请帮助大师?