Jetpack Infinite Scroll and IS Filter
-
I am using a Genesis Child theme (agency pro) and Jetpack’s Infinite Scroll.
I created a custom query to re-order posts on an archive page (category: travel-photography) based on a custom field called “ColorCode”
To implement Infinite Scroll along with the custom query I am using a filter hooked to IS query args.The result is:
Archive page – Loads Content Properly as page 1
On clicking “Load More”
Infinite Scroll – Paged 1 – reloads content properly with this as page 1
Infinite Scroll – Paged 2 – reloads content properly with this as page 2
Infinite Scroll – Paged 3 – reloads content properly with this as page 3Has anyone found a way to prevent page 1 from duplicating?
Here’s the code I’ve entered into my functions.php file:
//*Jetpack Infinite Scroll //*__add a name to the content div add_filter( 'genesis_attr_content', 'custom_attributes_content' ); function custom_attributes_content( $attributes ) { if ( is_archive() ) { $attributes['id'] = 'main-content'; } return $attributes; } //*__function to enable infinite scroll and hook it to the after theme set up function custom_infinite_scroll() { add_theme_support( 'infinite-scroll', array( 'type' => 'click', 'container' => 'main-content', 'posts_per_page' => 'true', 'wrapper' => 'infinity', 'render' => 'genesis_do_loop' ) ); } add_action( 'after_setup_theme', 'custom_infinite_scroll' ); //*__filter IS to orderby ColorCode function agency_infinite_scroll_query_args( $args ) { $args['order'] = 'ASC'; $args['orderby'] = 'meta_value'; $args['meta_key']= 'ColorCode' ; $args['category']= 'travel-photography'; return $args; } add_filter( 'infinite_scroll_query_args', 'agency_infinite_scroll_query_args' );
The site page is http://www.hirutmcleod.com/category/travel-photography
Any insight would be much appreciated. I’ve been driving myself crazy over this!
- The topic ‘Jetpack Infinite Scroll and IS Filter’ is closed to new replies.