Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    The function archive_supports_infinity() is used by Infinite Scroll to control which archives have IS enabled. That function contains a filter, infinite_scroll_archive_supported, that you can use to modify the default behaviour:
    https://plugins.trac.www.ads-software.com/browser/jetpack/trunk/modules/infinite-scroll/infinity.php#L863

    Within the function that you attach to that filter, you can leverage the WordPress conditional tags to limit which archives have Infinite Scroll support.

    Thanks for the information and link but… I still don’t understand the implementation. What code do I need to add, and where, to allow my search results to infinite scroll?

    Thread Starter alesub

    (@alesub)

    Yeah.. that explanation works to know how to limit the infinite scroll from being applied into a speciffic conditional tag, what I need is to remove the restriction it has with the search results. I have no limitations set, I added the infinite scroll support myself with the standard set of instructions.

    Thanks!

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    By default, Infinite Scroll is limited to the home page and the archive pages, as you can see in the archive_supports_infinityfunction:
    https://plugins.trac.www.ads-software.com/browser/jetpack/trunk/modules/infinite-scroll/infinity.php#L875

    If you want to change that default, you will have to create your own function to specify what is supported. If you want to add IS to search result pages, you will have to change $supported to include is_search (#), like so:

    function tweakjp_custom_is_support() {
    	$supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() );
    
    	return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );

    I have not tested that code, but that should work.

    Thank you! Yes, adding that to the functions.php page worked like a charm!! Much appreciated.

    I want to add IS support for search pages as well. I added the code above but my pages wound up being blank, white and empty. After changing the function name, the pages load, but IS isn’t activating. Got any tips? I’m using a child theme with twentytwelve.

    (I’ve seen your support elsewhere on the forum and I want to thank you for all of it. I’ve gotten a lot of help from your responses elsewhere).

    Here’s the code I plopped into functions.php (including my initialization code).

    function ftchild_twentytwelve_setup() {
    	add_theme_support(
    		'infinite-scroll',
    		array(
    			'posts_per_page' => 1,
    			'container'		 => 'infinite-content',
    			'wrapper'		 => false
    		)
    	);
    }
    add_action( 'after_setup_theme', 'ftchild_twentytwelve_setup', 12 );
    
    // Add infinite scroll support to search pages
    function add_infinite_to_search() {
    	$supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() );
    	return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'add_infinite_to_search' );

    I see line 976, and it looks like search might have IS functionality by default. Is that true?

    /**
    977	         * Allow plugins to filter what archives Infinite Scroll supports
    978	         *
    979	         * @uses current_theme_supports, is_home, is_archive, apply_filters, self::get_settings
    980	         * @return bool
    981	         */
    982	        public static function archive_supports_infinity() {
    983	                $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() );
    984
    985	                return (bool) apply_filters( 'infinite_scroll_archive_supported', $supported, self::get_settings() );
    986	        }

    Too late for me to retract my previous post, but part I of my problem is solved: I must have found this same page before because I used the same function name elsewhere to disable search on WooCommerce pages.

    But now there’s a part II to my problem: the posts that infinite scroll loads into search pages are just results from the homepage, they aren’t posts from the search results.

    So if you have any tips about debugging that… I’d much appreciate it! ??

    UPDATE:

    Found this ticket: https://www.ads-software.com/support/topic/jetpack-infinite-scroll-2?replies=14

    I’ll be following that.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    @nanoo_k I’m afraid we haven’t fixed this issue yet. You can follow our progress in this trac ticket:
    https://plugins.trac.www.ads-software.com/ticket/1706

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Infinite scroll not loading in search results’ is closed to new replies.