Jetpack Infinite Scroll Conflicting with Theme pre_get_posts $query->set
-
I’m outputting a custom post type into a 3-column grid that needs to leave One empty space for a different block of content.
To achieve this, I’m using $query->set inside of a pre_get_posts function:
function portfolio_posts( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if (is_tax('portfolio_category', 'custom-web-design') ) { $query->set( 'posts_per_page', 8 ); $query->set( 'orderby', 'menu_order'); $query->set( 'order', 'ASC'); return; } if (is_tax('portfolio_category', 'brand-identity') ) { $query->set( 'posts_per_page', 11 ); $query->set( 'orderby', 'menu_order'); $query->set( 'order', 'ASC'); return; } } add_action( 'pre_get_posts', 'portfolio_posts', 11);
I’m attempting to add a Load More button, so I’m using Jetpack’s Infinite Scroll plug-in.
Infinite Scroll also uses pre_get_posts, with an add_action priority of 10, which is why I set mine to 11.
Problem is, when I run the code, the Load More button doesn’t appear now ??
Is there any way to solve this without touching the core files of Jetpack?
Since I feel this particular question warrants some Stack Overflow Reputation points, here’s the link: https://stackoverflow.com/questions/33292748/jetpack-infinite-scroll-conflicting-with-theme-pre-get-posts-query-set
- The topic ‘Jetpack Infinite Scroll Conflicting with Theme pre_get_posts $query->set’ is closed to new replies.