需要有关WordPress分页脚本的帮助

时间:2015-07-06 作者:Harshad

请您检查一下分页脚本中的错误。事实上,我已经设置了4个帖子限制,在我的博客中大约有8个帖子。单击2分页时,它不会移动到下一页。

请检查link 以现场为例

<?php get_header(); ?>

<?php
$paged = ( get_query_var( \'paged\' ) ) ? absint( get_query_var( \'paged\' ) ) : 1;

// WP_Query arguments
$args = array (
    \'post_type\'              => the_post(),
    \'posts_per_page\'         => \'3\',
    \'paged\' => $paged
);
?>

<?php

// The Query
$cquery = new WP_Query( $args );
while ( $cquery->have_posts() ) : $cquery->the_post();
?>
<div class="row">
                        <div class="img"><a href="<?php the_permalink() ?>" class="imgPos"><?php the_post_thumbnail(\'full\'); ?></a></div>
                        <div class="text">
                            <h2><a href="<?php the_permalink() ?>" style="color:#545454;"><?php the_title(); ?></a></h2>
                            <h3 style="line-height: 1px;"><span class="floatL">By &nbsp;</span> <span class="floatL"> <?php the_author_posts_link(); ?> &nbsp;</span> <span class="floatL">&nbsp; - &nbsp;</span> <span class="floatL"><?php the_time(\'F jS, Y\'); ?></span><div class="clr"></div></h3>
                            <p><?php the_content(\'Read More\') ?></p>

                        </div> 
                        </div> 
<?php
$post->ID;
endwhile;

$big = 999999999; // need an unlikely integer
?>

<div class="row">
<div class="pagination">
<?php
echo paginate_links( array(
    \'base\' => str_replace( $big, \'\', esc_url( get_pagenum_link( $big ) ) ),
    \'format\' => \'?paged=%#%\',
    \'current\' => max( 1, get_query_var(\'paged\') ),
    \'total\' =>  $cquery->max_num_pages
) );
?>
</div>
</div>
<?php get_footer(); ?>

1 个回复
SO网友:bhavesh vala

在这里,您只需要更改$args数组。你有错误的论点。

$args = array (
    \'post_type\'              => \'post\',
    \'posts_per_page\'         => 3,
    \'paged\' => $paged
);

结束

相关推荐

Pagination custom query

我正在尝试制作一个自定义页面模板,以显示浏览次数最多的帖子。我可以回复帖子,但我很难弄清楚如何分页。以下是我所拥有的:$args = array(\'orderby\' => \'meta_value_num\', \'meta_key\' => \'post_views_count\', \'posts_per_page\' => 36 ); $loop = new WP_Query( $args ); while ( $