将静态首页上的循环从query\\u posts切换到wp\\u query。除分页链接(以前正常工作)外,其他所有链接都正常工作。示例可现场查看here 在“工作”部分。
这是我的循环:
<?php
$paged = (get_query_var(\'page\')) ? get_query_var(\'page\') : 1;
$args = array(\'category_name\'=>\'portfolio\',\'posts_per_page\'=>4,\'paged\'=>$paged);
$work_posts = new WP_Query($args);
if($work_posts->have_posts()) :
while($work_posts->have_posts()) :
$work_posts->the_post();
?>
<div class="box">
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
</a>
</div><!-- THUMBNAIL -->
<aside>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
</aside><!-- ASIDE -->
</div><!-- BOX -->
<?php endwhile; ?>
</div><!-- WORK ITEMS -->
<div class="navigation">
<div class="older">
<?php next_posts_link(\'load more\'); ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<h2>Sorry, there are no posts to display</h2>
<?php endif; ?>