That's how it's looks with 20 posts, and only four posts shows.
With this, I have 20 posts in this category, I'm showing on the single page only four of them, so i should get 5 pages of navi page plagin, but I get only two of them, and it's doesn't metter how many posts I have.
<?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 ) ); ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.