我面临一个奇怪的问题,显示按类别排序的特定类型自定义帖子的所有帖子。下面显示它们的代码在本地运行良好,但当我在服务器上查看页面时,它会返回一个包含三篇文章的归档页面。这怎么可能?
这是显示帖子的代码:
<?php $categories = get_terms(\'categor\', \'orderby=count&order=DESC&hide_empty=1\');
foreach( $categories as $category ):?>
<h2><?php echo $category->name; // Prints the cat/taxonomy group title ?></h2>
<?php $posts = get_posts(array(
\'post_type\' => \'downloads\',
\'taxonomy\' => $category->taxonomy,
\'term\' => $category->slug,
\'nopaging\' => true,
));
foreach($posts as $post):
setup_postdata($post); //enables the_title(), the_content(), etc. without
specifying a post ID ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<h3><i class="icon-file"></i> <?php the_title(); ?></h3>
<p><i class="icon-download-alt"></i> <a href="<?php the_field(\'file\'); ?>"
target="_blank">Download file</a></br><?php the_field(\'discription\'); ?></p>
<?php echo \'<hr/>\'; ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php endforeach; ?>