Finding current page number in Wordpress

前端 未结 5 1198
我在风中等你
我在风中等你 2021-02-18 23:39

I have added the following custom loop in my Wordpress template:

$args = array(
    \'category__not_in\' => array($featured_cat->term_id),
    \'posts_per_         


        
相关标签:
5条回答
  • 2021-02-19 00:05

    Not near a wordpress system to test this out at the mo, but you should be able to use:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    

    (obviously defaulting to 1, if it has not been sent through).

    0 讨论(0)
  • 2021-02-19 00:18

    This worked for me:

    <?php echo '(Page '.$page.' of '.$wp_query->max_num_pages.')'; ?>
    
    0 讨论(0)
  • 2021-02-19 00:19

    Use get_query_var('paged') like this

    <?php 
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    $args = array('category__not_in' => array($featured_cat->term_id), 'posts_per_page' => 10, 'post__not_in' => array($recent_post), 'paged' => $paged );
    query_posts($args); 
    ?>
    
    0 讨论(0)
  • 2021-02-19 00:20

    For 'Page x of y' I use this:

    <?php 
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    echo $paged.' of '.$wp_query->max_num_pages; 
    
    ?>
    
    0 讨论(0)
  • 2021-02-19 00:27

    using variable $paged.

    global $paged;
    echo $paged;
    
    0 讨论(0)
提交回复
热议问题