Title: Load more current wp_query??
Last modified: November 29, 2020

---

# Load more current wp_query??

 *  Resolved [devtat](https://wordpress.org/support/users/devtat/)
 * (@devtat)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/load-more-current-wp_query/)
 * Am I missing something obvious? I just need ALM to load the current page’s $wp_query
   posts… for some context, I’m applying both ‘meta_query’ and ‘tax_query’ filters
   to a post-type archive page via ‘pre_get_posts’ and $_POST variables.
 * I’ve tried re-creating my query with ‘alm_query_args’ but it fails at getting
   either $_POST or $_SESSION variables for the filters according to the debug.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/load-more-current-wp_query/#post-13722191)
 * [@devtat](https://wordpress.org/support/users/devtat/) Good question.
    ALM creates
   its own `WP_Query` so you won’t be able to just pass in an existing `WP_Query`
   and expect it to work. You could parse the returned query args and then pass 
   it in, but i’m not sure exactly what you’ve tried as you did not share any code.
 *  Thread Starter [devtat](https://wordpress.org/support/users/devtat/)
 * (@devtat)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/load-more-current-wp_query/#post-13723367)
 * Code is something like this in functions.php:
 *     ```
       function theme_folio_listing($args, $id){
       $args['post_type'] = 'folio';
       $tax_query = array( 'relation' => 'AND' );
   
       if( isset($_SESSION['source']) ){
        $args['meta_query'] = array(array( 'key'=>'author', 'value' => $_SESSION['source'], 'compare' => '=' ));
       }
       if( isset($_SESSION['format']) ){
         $tax_query[] = array( 'taxonomy' => 'folio_format', 'field' => 'id', 'terms' => $_SESSION['format'] , 'operator' => 'IN' );
       } else {
         $tax_query[] = array( 'taxonomy' => 'folio_format', 'field' => 'id', 'operator' => 'EXISTS' );
       }
       if( isset($_SESSION['tags']) ){
         $tax_query[] = array( 'taxonomy' => 'folio_tags', 'field' => 'id', 'terms' => $_SESSION['tags'], 'operator' => 'IN' );
       }
       $args['tax_query'] = $tax_query;
   
       return $args;
       }
       add_filter( 'alm_query_args_folio_listing', 'theme_folio_listing', 10, 2);
       add_filter( 'alm_debug', '__return_true' );
       ```
   
 * Then, on the archive page:
 *     ```
       do_shortcode('[ajax_load_more id="folio_listing" css_classes="section" container_type="section" offset="" posts_per_page="10" pause="false" transition_container_classes="folio-grid"]');
       ```
   
 * ALM Debug shows me that that my $_POST/$_SESSION fail to be read and fallback
   to ‘else’, so how can I pass variable data to ‘alm_query_args’ – is it possible?
   Query variables would need to change each time page is accessed/refreshed.
 *  Thread Starter [devtat](https://wordpress.org/support/users/devtat/)
 * (@devtat)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/load-more-current-wp_query/#post-13737921)
 * Adding `session_start()` inside the alm_query_args function seems to have finally
   fixed it.
 * Would have been nice to be able to pass the whole `$wp_query->get('tax_query')`
   value without having to re-create it though.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Load more current wp_query??’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [ALM](https://wordpress.org/support/topic-tag/alm/)

 * 3 replies
 * 2 participants
 * Last reply from: [devtat](https://wordpress.org/support/users/devtat/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/load-more-current-wp_query/#post-13737921)
 * Status: resolved