Infinite Scroll and DFP
Infinite Scroll and DFP
Infinite Scroll and DFP
I added the render and this is the full code. function mytheme_infinite_scroll_init() { add_theme_support( ‘infinite-scroll’, array( ‘container’ => ‘content’, ‘render’ => ‘mytheme_infinite_scroll_render’, ‘container’ => ‘content’, ‘posts_per_page’ => 2, ) ); } function mytheme_infinite_scroll_render() { while( have_posts() ) { the_post(); get_template_part( ‘template-parts/content’, get_post_format() ); } } add_action( ‘init’, ‘mytheme_infinite_scroll_init’ ); you may find a problem that … Read more
Changing sort order for presentation by Jetpack infinite scroll
The problem lies in the ‘container’ => ‘content’. The container parameter is the core of adding infinite scroll to your theme: it specifies the ID of the HTML element to which infinite scroll should add additional posts to. You need to add ID ( for example: product-wrapper ) to products wrapping element which is going … Read more
Using infinite scroll ajax load more with search parameter
Load MediaPlayerElement after Infinity Scroll loads more posts
This is just one approach. You have the Load More button and once you click that you request for more posts via Ajax. You need to master Ajax in WordPress first and call WP_Query with specific arguments to fit your case. Once you get results via Ajax you need to use JavaScript or JQuery to … Read more
Stand down! I got it with ‘pre_get_posts’: add_action( ‘pre_get_posts’, ‘pre_service_archive’ ); function pre_service_archive() { if( is_post_type_archive( ‘service’ ) ) remove_theme_support( ‘infinite-scroll’ ); }
Your div wrapper is within your while loop, and split by your if clause. This cannot work properly, since your loop will generate up to 14 divs with the id ajax. Put the opening div tag after if ( $the_query->have_posts() ) { and the closing after wp_reset_postdata(); and you should be fine. Edit Are you … Read more
You probably need to define a new loop function for the Custom Post Type to pass to the render parameter. As in the example from https://jetpack.com/support/infinite-scroll/ /** * Add theme support for infinity scroll */ function twenty_ten_infinite_scroll_init() { add_theme_support( ‘infinite-scroll’, array( ‘container’ => ‘content’, ‘render’ => ‘twenty_ten_infinite_scroll_render’, ‘footer’ => ‘wrapper’, ) ); } add_action( ‘after_setup_theme’, … Read more