• Hello,

    I’ve got a page with a Form tht filters the posts. For ex il the user selects a author in the form, the page will load a specific query post.
    Unfortunatly, when I click on age 2, the $_POST is not sent to the page,and so it returns the page 2 of all the posts from all authors…

    I don’t know if I’m clear.

    if(isset($_POST['author'])){
    
     $author= $_POST['author'];
    
     $args = array(
    'post_type'     => 'formationcontinue',
    'posts_per_page' =>  10,
    'order'    => 'DESC',
    'author' => $author,
    'paged' => get_query_var('paged')
    
    ); } else {
    $args = array(
    'post_type'     => 'formationcontinue',
    'posts_per_page' =>  10,
    'order'    => 'DESC',
    'paged' => get_query_var('paged')}
    
     if( $the_query->have_posts() ){
    // The Loop
    while ( have_posts() ) : the_post();
    ?>
    
    <li>
     <a>"> <?php the_title(); ?></a>
    </li>
     <?php
    endwhile;
    wp_pagenavi( array( 'query' => $the_query ) );
    
    // Reset Query
    wp_reset_postdata();
    }

    Do you know how I can make this work ?

    Thx!!!!

    https://www.ads-software.com/plugins/wp-pagenavi/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, I think I am trying to do something similar. I was hoping that wp_pagenavi( array( 'query' => $the_query ) ); would pass the current query.

    I’m not feeling on top of my game at the moment and having trouble understanding exactly what passing the query to wp_pagenavi does. Does it make $the_query accessible to the new page? If so how does one access it?

    Sorry if these are naive questions, I’m just struggling a bit at the moment.

    So basically I have a filter menu on the page for location and category. I use the post method to send and receive these details and feed them into a new WP_Query. I then loop over the query to show the posts. Fine. But when I try to add pagination and go to another page it looks like the filter variables are not being sent and therefore I am actually getting page 2 of a loop without any filter variables set.

    So I need a way to either pass the filter variables on to the new page or to send $the_query to the new page and tell the code not to create a new WP_Query but to use the details in $the_query.

    Any help would be appreciated and I’m really sorry if this is a tedious set of questions.

    Thanks.

    Hi guys, I’m having the exact same issue, I’m filtering posts using variables pulled with $_POST and when the navigation is selected these values are lost / not applied.

    Did anyone have any look / have a possible solution that could be worth testing out.

    Cheers.
    ^JD

    I think I went back to using paginate_links
    See the examples here: https://codex.www.ads-software.com/Function_Reference/paginate_links

    Um, I’m currently rewriting the plugin that used pagination so I can elaborate further when I get there.

    @benattenborough cheers, I’ve got my fingers crossed that the plugin creator possibly knows of a work around, I’ve used the plugin throughout my site now and it works perfectly if only it could reference the necessary values when a pagination links submitted. Plus it works perfectly with a WP_User_Query script I have running.

    It’s one of those where I feel so close but at the same time totally stumped for a workaround.

    ^JD

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get pagination with $_POST’ is closed to new replies.