WordPress.org

Ready to get started?Download WordPress

Forums

Infinite-Scroll
[resolved] Loading Infinite Scroll in a Custom header for a Page (4 posts)

  1. sosukeinu
    Member
    Posted 2 years ago #

    Hello, I'm using version 2.0b2.110822 of infinite scroll. I know WordPress is not meant to be used this way, but I'm still trying to bend it to my will. I have a page using a custom template, custom header, and custom loop with pagination. I'm trying to get infinite scroll to load in the header, specifically for this page, and this loop. On my other pages I get something like this :
    <script type='text/javascript' src='http://mysite.com/fiction/wp-content/plugins/infinite-scroll/infinitescroll.init.js.php?p=YToyOntBLAHBLAHBLAH=='></script>
    Now, when I add this to the header of the page, infinite scroll works like a charm, but ignores my loop, instead posting the content from the page I copied the code from. What would I have to add to the header file in order for infinite scroll to initialize correctly for this page? Or would I need to create a function in the functions.php file? Something like, if (this page)add_action wp_head Yada, yada, yada? Thank you for any direction here.

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

  2. beaver6813
    Member
    Plugin Author

    Posted 2 years ago #

    hi sosukeinu,
    infinite-scroll uses WordPress hooks to decide on what pages to load. It also checks to see if there are posts on the page etc.
    In:
    infinite-scroll/includes/infinite-scroll.class.php there is:

    public static function addInfiniteScroll()
    	{
    	global $user_level,$wp_query;
    	$load_infinite_scroll = true;
    	/* Lets start our pre-flight checks */
    	if (get_option('infscr_state') == 'disabled' || is_page() || is_single() || (get_option('infscr_state') == 'disabledforadmins' && $user_level >= 8) || (get_option('infscr_state') == 'enabledforadmins' && $user_level <= 8) || !have_posts())

    The if statement at the bottom looks mighty complicated but seperate it out to make it easier to read. It basically checks if infinite-scroll shouldn't be loaded on the page. (For example if it has no posts). You might have to edit it here to make some exceptions :)

    Let me know if you need any more guidance.

  3. sosukeinu
    Member
    Posted 2 years ago #

    I can see right away the problem for me is right here is_page() and upon deleting this, it works a charm. As ever,...thank you a ton for your help and knowledge beaver6813. Is there a way that I can make this alteration so that it isn't overwritten with each upgrade, or will i just need to remember, and fix it? Thank again.

  4. beaver6813
    Member
    Plugin Author

    Posted 2 years ago #

    Unfortunately there's not, its a core file so it'll always be updated. I'll add it to my "to do" list though (to allow the user to edit the load conditions, perhaps under an advanced menu somewhere).
    I'm fairly slow with my official releases (primarily because I don't have a lot of time to support at the moment so I want to keep it uber stable). So you shouldn't need to fix it often :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic