WordPress.org

Ready to get started?Download WordPress

Forums

use two wp_pagenavi in one page (4 posts)

  1. sfarid
    Member
    Posted 5 years ago #

    I want to show posts with cat=3, let say newsA
    and below posts with cat=6, let say newsB
    For each newsA and newsB I use wp_pagenavi();
    The problem is, if I click, for example page 3 of newsA, the newsB also changes.
    Is it possible to use wp_pagenavi() two times in one page?

  2. Lester Chan
    Member
    Posted 5 years ago #

    If I am not wrong, it is not possible.

  3. sfarid
    Member
    Posted 5 years ago #

    I solved this problem.
    for the newsA a set
    if(function_exists('wp_pagenavi')) {
    wp_pagenavi(0);
    }

    and for the newsB a set
    if(function_exists('wp_pagenavi')) {
    wp_pagenavi(1);
    }

    in wp_pagenavi i send this variable $number back
    function wp_pagenavi($number){
    ...
    echo 'a href="'.get_pagenum_link($i).'&pagenavi='.$number.'" title="'.$page_text.'"'.$page_text.'/a';
    ...
    }

    now I cann handle this variable in my template like this:
    $myPageNaviLink = "&paged=".$wp->query_vars['paged'];
    $wpQuery="cat=3&showposts=5";
    if ($_GET['pagenavi']==0) {
    $wpQuery = $wpQuery.$myPageNaviLink;
    }
    query_posts($wpQuery);
    ...
    if(function_exists('wp_pagenavi')) {
    wp_pagenavi(0);
    }
    ...
    $wpQuery="cat=6&showposts=5";
    if ($_GET['pagenavi']==1) {
    $wpQuery = $wpQuery.$myPageNaviLink;
    }
    query_posts($wpQuery);
    ...
    if(function_exists('wp_pagenavi')) {
    wp_pagenavi(1);
    }

  4. Coffee4cr
    Member
    Posted 5 years ago #

    Hey sfarid,
    I'm trying to use your trick, because it's exactly what i need on my site.
    But i'm still unable to use it properly.
    I'm using the most recent pagenavi plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic