我正在创建自定义主题,还有自定义文章类型。 但是,自定义帖子类型的分页不起作用。我尝试了Stack Overflow的所有可能的解决方案,但都是徒劳的。自定义文章类型分页不起作用
下面的代码:
<?php global $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 3,
'post_type' => 'services',
'orderby' => 'date',
'order' => 'DESC',
'nopaging' => false,
'paged'=>$paged
);
$the_query = new WP_Query($args); ?>
<div class="service-content clearfix">
<ul class="clearfix">
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php $word_count = strlen(wp_strip_all_tags($post->post_content));
$id = get_the_ID();?>
<li class="col-sm-4 wow fadeInDown animated" data-wow-delay="300ms" data-wow-duration="500ms">
<figure class="image">
<?php the_post_thumbnail('medium'); ?>
</figure>
<?php if($word_count<269){ ?>
<h3><?php echo $post->post_title; ?></h3>
<p><?php echo $post->post_content; ?></p>
<?php } else{ ?>
<h3><?php echo $post->post_title; ?></h3>
<?php echo $post->post_content; ?>
<?php } ?>
</li>
<?php endwhile;
next_posts_link();
previous_posts_link();?>
<?php wp_reset_query(); ?>
<?php endif; ?>
</ul>
</div>
这里,posts_per_page
是工作,但Pagination
不工作,任何帮助吗?
嗯,它只是显示下一个和上一个链接。它什么都不做:/ –