Support » Plugin: WP-Paginate » [Plugin: WP-Paginate] Pagination working on subpage but not homepage

Viewing 2 replies - 1 through 2 (of 2 total)
  • Please help!

    Thank you.

    The problem does seem to be specific to homepage pagination. The way this plugin determines the page will always return the paginated links for page 1 by default, while working everywhere else on the site.

    You can set your own page number during your call to wp_paginate( $args ) by passing it into the $args array. This is an admittedly ugly solution, but I got it working by adding these two functions to the functions.php file:

    function bw_get_page_number( $args = array() ){
    	$url =  preg_split( '/\/page\//' , current_page_url() );
    	$page = get_query_var( 'paged' );
    	if( !$page ){
    		if( !empty( $url[1] ) ){
    			$page = preg_replace( '/[^0-9]/' , '' , $url[1] );
    		} else {
    			$page = 1;
    		}
    	}
    	if( $page < 2 ){ $page = 1; }
    	return $page;
    }
    
    function bw_get_page_count(){
    	global $wp_query;
    	$posts_per_page = intval( get_query_var( 'posts_per_page' ) );
    	$pages = intval( ceil( $wp_query->found_posts / $posts_per_page ) );
    	return $pages;
    }

    And the call to wp_paginate( $args ) looks as follows:

    $args = array( 'page' => bw_get_page_number() , 'pages' => bw_get_page_count() );
    echo wp_paginate( $args );

    There may be several reasons why this will not immediately work for you, so I’ll be sure to check back on this topic for your reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP-Paginate] Pagination working on subpage but not homepage’ is closed to new replies.