[英]WordPress plugin pagenavi, I can't see more then 2 pages, even with 100+ posts
这就是 20 个帖子的样子,但只有 4 个帖子显示。
有了这个,我在这个类别中有 20 个帖子,我在单页上只显示了其中的四个,所以我应该得到 5 页的导航页面 plagin,但我只得到了其中的两个,并且不知道如何我有很多帖子。
<?php
/**
* Template Name: strategy
*/
get_header(); ?>
<div class="template">
<div class="container">
<div class="wrapper">
<div class="breadcrumb">
<?php if (function_exists('bcn_display')) {
bcn_display();
} ?>
</div>
<div class="page_title">
<h1><?php single_cat_title(); ?></h1>
</div>
<div class="articles_page__wrapper">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
global $post;
$args = array(
'numberposts' => 20,
'category' => 3,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'paged' => $paged,
);
$myposts = get_posts($args);
foreach ($myposts as $post) {
setup_postdata($post); ?>
<div class="item">
<div class="img">
<a href="<?php the_permalink(); ?>">
<img src="<?php the_post_thumbnail_url('small'); ?>"
alt="<?php the_title(); ?>">
</a>
</div>
<div class="group">
<div class="title">
<a href="<?php the_permalink(); ?>">
<h3><?php the_title(); ?></h3>
</a>
</div>
<div class="description">
<p><?php echo excerpt(40); ?></p>
</div>
</div>
</div>
<?php }
wp_reset_postdata(); ?>
</div>
<article>
<?php
$id = 8;
$post = get_post($id);
echo $content = $post->post_content;
?>
</article>
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
尝试像这样更新 wp_pagenavi 使用:
<?php if (function_exists('wp_pagenavi')) wp_pagenavi( array( 'query' => $myposts ) ); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.