WordPress.org

Ready to get started?Download WordPress

Forums

Infinite-Scroll
Can this work on archives/custom pages templates? (2 posts)

  1. Skeary
    Member
    Posted 1 year ago #

    On the homepage it says this only works on the main page, but from people talking it seems like maybe that's no longer the case?

    I'm trying to implement an infinite-scroll solution for tag archives and a page template that shows posts, and I'm getting the error 'infinite_scroll is not defined'

    My custom page contains the WP_Query in it like this:

    $args = array(
    	'posts_per_page'=> 4,
    	'post_type' => 'post'
    );
    
    $wp_query = new WP_Query( $args );
    
    if ( $wp_query->have_posts() ) : ?>
    ...

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

  2. dhelm
    Member
    Posted 1 year ago #

    Two things to consider:

    First, you have to hack the plug-in code to make sure it works on any page post-type. For version 2.0, the line to be modified is in the file infinite-scroll.class.php:

    /* Lets start our pre-flight checks */
    	if( is_single() || !have_posts() )

    should what it looks like after deleting "is_page() ||" from the list. For version 2.5 the check is somewhere else, but I downgraded, so I'm not sure where it is, but just search for the keyword "if ( is_singular() )" and change it to the line above. Keep in mind this file will be over-written if you upgrade the plugin, so you'll have to always go back and hack at it again.

    As for your theme, first make sure pagination works on your template pages. Make sure your next/back page buttons are working and that urls like "baseurl.com/pagename/page/2/" work right.

    If they don't, that is the problem to fix first and requires a work around if your pagination is to be used for a secondary loop.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic