WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Infinite scroll not loading in search results (9 posts)

  1. alesub
    Member
    Posted 1 year ago #

    Apparently jetpack doesn't apply its infinite scroll to the search page. First I though it was my theme implementation, but then switched to twenty twelve to find out that the same was happening.

    Any reason why it's not supported?

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    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:
    http://plugins.trac.wordpress.org/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.

  3. kristanlh
    Member
    Posted 1 year ago #

    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?

  4. alesub
    Member
    Posted 1 year ago #

    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!

  5. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    By default, Infinite Scroll is limited to the home page and the archive pages, as you can see in the archive_supports_infinityfunction:
    http://plugins.trac.wordpress.org/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.

  6. kristanlh
    Member
    Posted 1 year ago #

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

  7. nanoo_k
    Member
    Posted 8 months ago #

    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	        }
  8. nanoo_k
    Member
    Posted 8 months ago #

    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: http://wordpress.org/support/topic/jetpack-infinite-scroll-2?replies=14

    I'll be following that.

  9. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 8 months ago #

    @nanoo_k I'm afraid we haven't fixed this issue yet. You can follow our progress in this trac ticket:
    http://plugins.trac.wordpress.org/ticket/1706

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic