首先,作为wordpress的初学者,不要犹豫。其次,对于带有相应帖子的类别列表,您需要执行以下操作:
<ul class="et_pb_tabs_controls clearfix tab-ul">
<?php
dynamic_sidebar(\'sidebar\');
$cate_id=get_query_var(\'cat\');
global $sitepress;
$paged = ( get_query_var(\'page\') ) ? get_query_var(\'page\') : 1;
$sitepress->switch_lang( $sitepress->get_default_language() );
$args = array(
\'type\' => \'post\',
\'child_of\' => 0,
\'parent\' => \'\',
\'orderby\' => \'name\',
\'order\' => \'DESC\',
\'hide_empty\' => 1,
\'hierarchical\' => 1,
\'exclude\' => 1,
\'include\' => \'\',
\'number\' => \'\',
\'taxonomy\' => \'category\',
\'pad_counts\' => false
);
$flag=0;
$inc=0;
foreach (get_categories( $args ) as $category):
$flag=($inc==0)?0:1;
if( !is_array($cate_id) && $cate_id=="")
$category_arr[]= $category->term_id;
?>
<li class="et_pb_tab_0 <?php echo ($flag==0)? \'et_pb_tab_active\':\'\';?>"><a href="#<?php echo $category->name; ?>"><?php echo $category->name; ?></a></li>
<?php
$inc++;
endforeach; ?>
</ul>
<?php foreach ($category_arr as $category_id):
$arr=array(
\'post_type\' => \'post\',
\'order\'=>"ASC",
\'cat\'=>$category_id,
\'posts_per_page\' => -1,
\'paged\' => $current_page,
\'suppress_filters\' => false
);
$wpb_all_query = new WP_Query($arr); ?>
<div class=" et_pb_row et_pb_row_1 full-width">
<?php if ( $wpb_all_query->have_posts() ) :
$increment=0;
while ( $wpb_all_query->have_posts() ) :
if(($increment%3)==0){
echo \'</div><div class=" et_pb_row et_pb_row_1 full-width">\';
}
$wpb_all_query->the_post();
?>
<div class="et_pb_column et_pb_column_1_3 et_pb_column_1">
<div class="et_pb_posts et_pb_module et_pb_bg_layout_light et_pb_blog_0">
<div class="entry box">
<!--If no results are found-->
<?php $post_link= get_permalink(); ?>
<?php $img_path=get_the_post_thumbnail(); ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id()); ?>
<a href="<?php echo $post_link;?>">
<?php if($url !=""){
?>
<img src="<?php echo $url; ?>" alt="">
<?php } ?>
</a>
<a href="<?php echo $post_link;?>"><h1><?php the_title(); ?></h1></a>
<p class="box-content"><?php echo(get_the_excerpt()); ?></p>
<div class="profile-box">
<img src="<?php bloginfo(\'template_url\'); ?>/img/profile-icon.png" alt="" id="" data-height-percentage="54" data-actual-width="18" data-actual-height="28">
<div class="pro-name"><h4><?php echo get_the_author(); ?></h4>
<span><?php echo get_the_date(); ?></span>
</div>
</div>
</div><!--End if no results are found-->
</div> <!-- .et_pb_posts -->
</div><!-- .et_pb_column -->
<?php
$increment++;
endwhile;
wp_reset_postdata();
endif;
?>
</div>