我正在尝试创建类别选项卡,以显示所选类别选项卡中的帖子。我已经用我的方式尝试过了,但我每个类别只能得到一个帖子,而它应该返回该类别中的所有帖子。我正在粘贴下面的代码,有人能帮我解决这个问题吗?
<ul id="download-tab" class="nav nav-tabs resp-tabs-list">
<?php
$args = array(
\'orderby\' => \'name\',
\'parent\' => 13
);
$categories = get_categories( $args );
$i=0;
foreach ( $categories as $category ) {
$i++;
echo \'<li><a id="#\'.strtolower(str_replace(\' \', \'\', $category->name)).\'" href="dtab\'.$i.\'">\' . $category->name . \'</a></li>\';
}
?>
</ul>
<div class="tab-content resp-tabs-container" id="download-content">
<?php
$pargs = array(
\'orderby\' => \'name\',
\'parent\' => 13
);
$categories_loop = get_categories( $pargs );
foreach ( $categories_loop as $category_loop ) {
query_posts(\'category_name=\'.$category_loop->slug.\'&posts_per_page=-1&order=desc\'); $j=0;
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();
$j++ ?>
<div class="tab-pane" id="dtab<?php echo $j ?>">
<table class="table table-hover">
<tr>
<th>DATE</th>
<th>TITLE</th>
<th>SIZE</th>
<th></th>
</tr>
<?php
$file_size = rwmb_meta(\'file_size\');
$file_url = rwmb_meta( \'file_url\');
?>
<tr>
<td><?php the_time(\'d/m/Y\'); ?></td>
<td><?php the_title(); ?></td>
<td><?php echo $file_size; ?></td>
<td><a href="<?php echo $file_url ?>" class="button3 download_btn" target="_blank">DOWNLOAD</a></td>
</tr>
</table>
</div>
<?php
endwhile; ?>
<div style="width:45%; float:left; font-weight:bold; margin-top:20px;"><?php //previous_posts_link(\'PREV\'); ?></div>
<div style="width:45%; float:right; text-align:right; font-weight:bold; margin-top:20px;"><?php //next_posts_link(\'NEXT\',$download_query->max_num_pages); ?></div>
<?php wp_reset_query();?>
<?php else: ?>
<p><?php _e( \'Sorry, no content found.\' ); ?></p>
<?php endif;
} ?>