WordPress.org

Ready to get started?Download WordPress

Forums

Infinite-Scroll
FIXED: Infinite Scroll on Custom Post Page (12 posts)

  1. jprauch
    Member
    Posted 1 year ago #

    In 'infinite-scroll/infinite-scroll.php' scroll to the bottom and find:

    /**
    * Determines if the jQuery plugin and corresponding options should
    * be output onto the page.
    *
    * @return bool
    */
    function shouldLoadJavascript() {
    // Don't need to load the plugin on single pages
    if (is_singular()) {
    return false;
    }

    return true;
    }

    Change 'false' to 'true'

    http://wordpress.org/extend/plugins/infinite-scroll/

  2. clickmac
    Member
    Posted 1 year ago #

    what does this do exactly?

  3. thisismyalterego
    Member
    Posted 1 year ago #

    the "is_singular" function checks if the wordpress page is a single page or single post (that can be edited via the backend) or if it's a data-collector (like blog, archive, etc which are putting out multiple single entries)

    for some reason the infinite-scroll developers decided to disable the whole functionality when the browser is on this "single pages"

    when changing false with true, also single pages work.

  4. sloweye
    Member
    Posted 1 year ago #

    I think the decision to use is_singular prevents the infinite scroll script from adding to load times on pages where it is not needed. That is one advantage, anyway.

    Unfortunately is_singular also prevents the script from loading on custom post type archives. In Codex here

    Replacing is_singular with is_single (in the Codex http://codex.wordpress.org/Function_Reference/is_single) allows custom post archives and custom queries to load the script, while still leaving the code out on single page views where it would serve no purpose.

    So at the bottom of infinite-scroll/infinite-scroll.php this:

    /**
    	 * Determines if the jQuery plugin and corresponding options should
    	 * be output onto the page.
    	 *
    	 * @return bool
    	 */
    	function shouldLoadJavascript() {
    		// Don't need to load the plugin on single pages
    		if (is_singular()) {
    			return false;
    		}
    
    		return true;
    	}

    Is replaced by this:

    /**
    	 * Determines if the jQuery plugin and corresponding options should
    	 * be output onto the page.
    	 *
    	 * @return bool
    	 */
    	function shouldLoadJavascript() {
    		// Don't need to load the plugin on single pages
    		if (is_single()) {
    			return false;
    		}
    
    		return true;
    	}
  5. thisismyalterego
    Member
    Posted 1 year ago #

    Good suggestion sloweye!

  6. jprauch
    Member
    Posted 1 year ago #

    Another option I used for a project is making the load 'page' specific. Where i didn't need any other pages to load the script. Here's an example for only loading the script on a page called, 'blog'.

    /**
    * Determines if the jQuery plugin and corresponding options should
    * be output onto the page.
    *
    * @return bool
    */
    function shouldLoadJavascript() {
    // Don't need to load the plugin on single pages
    if (is_page('blog')) {
    return true;
    }

    return true;
    }
    }

  7. owh
    Member
    Posted 1 year ago #

    @jprauch, Thanks! It works.

  8. hullen
    Member
    Posted 1 year ago #

    To not need add ever custom page, just replace is_singular() by is_single(). Is much easy and fast!

  9. csmillie
    Member
    Posted 1 year ago #

    Hi,
    Is there any plans to get this committed? I just ran into it when I setup my wordpress instance to use a specific page instead of page of posts...

    Thanks,

    Colin

  10. Wnd
    Member
    Posted 1 year ago #

    Is it possible to use it for category.php pages?

  11. virtualgeek
    Member
    Posted 1 year ago #

    @sloweye

    It worked perfectly for me. Thank you!

  12. hugerobots
    Member
    Posted 1 year ago #

    I've been wrestling with this on my pages for months now and I think this is on the right track, but still not quite working... Or my brain just hasn't been able to soak in the right vitimins.

    If anyone can lend a hand to this issue with what my structure is I'd be hugely grateful.

    What I think is happening is there may be a problem with my WP_Query. At least that's what a number of other sources I've read have lead me to believe.

    http://theciv.com/vancouver/

    Please take a second search the loaded source for 'thirdLoop'.

    There you'll see the pagination links at the bottom of the thirdLoop container, but the infinite-scroll plugin isn't registering at all.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic