I was going to create my own question and answer it, but this looks as good a place as any. The way I solved this, is by using $_SESSION. Keep in mind I am using infinite-scroll, so I can tell when the page is being fetched via ajax as opposed to being actually navigated to in the browser.
So here’s the steps/pseudo-code:
- Clear Session Variables
- Run “Default” loop and get html
- User filters results -> get results from new loop
- Set Session Variables so page knows which loops to run
- User scrolls down -> get results from current page, but for next page
- This page displays a loop conditionally based on the session variables
- ??????
- Profit
I would just post my code, but it is pretty large so I’d rather not. If you can’t figure it out, let me know though and I will post the skeleton of the code.
Related Posts:
- Get the number of posts from the current page results
- Five posts from a category in footer
- Show number of posts AND number on current page (cannot make it work)
- Some doubts about how the main query and the custom query works in this custom theme?
- Multiple WP_Query loops with Pagination
- WP_Query vs get_posts
- Pagination returns 404 after page 20
- Order posts by ID in the given order
- Pagination with WP_Query is buggy – working for some pages, but not the others
- WordPress Custom Query to show posts from last x years
- Query Custom Meta Value with Increment
- Pagination with 5 posts per page
- Pagination/infinite scroll with WP_Query and multiple loops
- Pagination Not working on Home Page with 2 Query
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- Transient pagination not working properly
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Woocommerce custom loop to show all the products [closed]
- How to bring specific post to front of wordpress loop?
- Too many posts cause slow load when paginating
- Pagination stops at page 6
- Paginated HTML Sitemap
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- 2 loops on page – one with orderby rand second orderby date
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination is broken and I need help fixing it
- Query posts by specific word on title
- Storing query variable and then using wp_reset_query
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- Blog post per page setting conflicting with custom WP_Query?
- posts_per_page not working for first page of pagination
- Some doubts about how the main query and the custom query works in this custom theme?
- Custom loops, sticky posts, and pagination nightmare
- pagination not working for category.php (custom post types in categories)
- How do I get my custom query to work with search results after the first page?
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- How to provide meta_key array to wp_query?
- get_posts output always same post
- Pagination on category.php and tag.php not working
- How to create custom query by keyword in post title?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- 2 queries with counters
- Second loop pagination changes URL, not content
- I am officially missing something about transient posts
- Query Not working as expected
- filter posts by meta key with pagination
- Trouble Making WP_Query paged
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Pagination inside the blog page not working
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- Custom Query Pagination not working on static front page
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- Paging works correctly on local version, but not live?
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Problem with custom WP_Query and underlying pagination/posts_per_page
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Pagination returns 404 after page 20
- Ordering Posts by parent category, name ascending
- custom query – offset to pagination
- Pagination not working with WP_QUERY
- No content found on page 2 of pagination with 1 post per page
- wp_query pagination links producing 404
- Converting an existing query_posts to WP_Query
- Loop being strainge
- Multiple loop for “featured” items returns wrong posts
- Pagination in custom query not working [duplicate]
- Multiple loops on index page with sticky post and pagination
- Pagination problem with multiple loops on the same page
- WordPress Post Looping? [duplicate]
- Pagination in category.php not functioning
- Pagination only showed when no category is set in wp_query
- Can I force WP_Query to return no results?
- paginate_links() adds empty href to first page and previous link
- Get array of posts from the current archive page loop
- Pagination not working on static page
- Converting multiple loops into one single loop with pagination
- Include latest author posts with pagination in single template?
- Create multiple sections for all categories and then queries all the posts for each of those categories