• I am showing posts conditionally
    for eg.

    $args = array(
    	'post_type'=> 'post',
    
    	'order'    => 'DESC',
    );
    
    if($sort_by == 'recent'){
    	$args['order'] = 'DESC';
    	$args['posts_per_page'] = 2;
    
    }
    $args['paged'] = get_query_var('paged');

    When $sort_by == ‘recent’ than it display only 2 posts, but also display pagination,

    pagination code is
    ` wp_pagenavi( array( ‘query’ => $query) );
    wp_reset_postdata();`

    Please Help me!!!
    I am stuck,

    Thanks in Advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Can you not show the pagination when $sort_by == recent?

    if ( $sort_by != 'recent' ) wp_pagenavi( array( 'query' => $query) );
    Thread Starter dinesh786

    (@dinesh786)

    thanks vtxyzzy, for reply,

    I can, But thought there is any way in wordpress, when we can hide pagination when we using $args[‘posts_per_page’] = 2;
    OR
    Is there not any way to set total number of rows to display,
    so it will not display pagination

    like if we set (if any query var or method exist) display total row = 2
    instead of posts_per_page = 2
    than it will not show pagination.

    welcomes all replies ??

    If you test for posts_per_page == 2, I think you will get the same results as I showed before:

    if ( $args['posts_per_page'] == 2 ) wp_pagenavi( array( 'query' => $query) );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to display recent post without pagination’ is closed to new replies.