【发布时间】:2015-09-15 01:22:36
【问题描述】:
有没有办法修改 the_content() 函数?我想在显示自定义分类负和正分类时添加一个 CSS 类。
例子:
<p class="positive">this is a content for the positive taxonomy</p>
<p class="positive">this is a content for the positive taxonomy</p>
<p class="negative">this is a content for the negative taxonomy</p>
我想在author.php代码中应用它:
<?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; ?>
带有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' );
}
});
PS:我在这里使用自定义帖子类型和自定义分类法,分为正面和负面两类。
【问题讨论】:
标签: php css wordpress custom-taxonomy