您可以在循环中检查帖子类型并将类添加到该帖子
请检查内容 template_part
尝试修改模板部分,如下所示
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
global $post;
<span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php the_post_thumbnail('large');?>
</a>
</span>
<?php endwhile; // end of the loop. ?>
将此添加到 function.php
add_filter( 'post_class','your_post_class' , 20, 3 );
public function your_post_class( $classes, $class, $post_id ) {
if ( 'basico' == get_post_type() ){
$classes[] = 'basico_class';
}elseif ( 'directorio' == get_post_type()){
$classes[] = 'directorio_class';
}
return $classes;
}