Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

.load() method returns 404 on second page when using CPT's in main loop (WordPress plugin) #77

Closed
andrewryno opened this Issue Aug 2, 2011 · 7 comments

Comments

2 participants

I have 1 post and about 10 posts that are in assorted custom post types and I'm modifying the main loop in index.php to include those post types. However, the plugin doesn't seem to realize this and returns a 404 for /page/2/ even though I can access that page via my browser. I've dug through the source of the plugin and I can't seem to find anywhere that would be causing this problem.

I'm using the latest version at the time (1.5.100504) and made only a couple modifications (which allow for manual-trigger.js to be used). Nothing that would cause this problem.

Note that it was working with custom post types when the 1 true post was on page 2, but it doesn't work when it's on page 1 and the only posts on page 2 are CPT's.

Any ideas?

Played around with my code and it seems like using this will work:

add_filter( 'pre_get_posts', 'theme_get_posts' );
function theme_get_posts( $query ) {
    if ( is_home() ) $query->set( 'post_type', array( 'post', 'audio', 'link', 'video' ) );
    return $query;
}

but using this will not:

query_posts( array(
    'post_type' => array(
        'post',
        'link',
        'audio',
        'video'
    ),
    'paged' => $paged
) );

I still say it's an issue that should be fixed if it can be, but there's a way to get around it in the meantime.

Contributor

samcleaver commented Aug 3, 2011

Hi andrewryno,
Could you confirm which version of the Wordpress plugin you are using?

--Sam Cleaver

On Wed, Aug 3, 2011 at 12:29 AM, andrewryno <
reply@reply.github.com>wrote:

I have 1 post and about 10 posts that are in assorted custom post types and
I'm modifying the main loop in index.php to include those post types.
However, the plugin doesn't seem to realize this and returns a 404 for
/page/2/ even though I can access that page via my browser. I've dug through
the source of the plugin and I can't seem to find anywhere that would be
causing this problem.

I'm using the latest version at the time (1.5.100504) and made only a
couple modifications (which allow for manual-trigger.js to be used). Nothing
that would cause this problem.

Note that it was working with custom post types when the 1 true post was on
page 2, but it doesn't work when it's on page 1 and the only posts on page 2
are CPT's.

Any ideas?

Reply to this email directly or view it on GitHub:
paulirish#77

Version 2.0b2.110713

I guess the 1.5.100504 would be for the main jQuery plugin.

Contributor

samcleaver commented Aug 3, 2011

Okies, the Wordpress plugin calls a function:

/*
Because recently (3.0) WP doesn't always throw a 404 when posts aren't found.
Infinite-Scroll relies on 404 errors to terminate.. so we'll force them. */
function wp_inf_scroll_404($wp)
    {
    if(!have_posts())
        {
        header("HTTP/1.1 404 Not Found");
        header("Status: 404 Not Found");
        }
    }```

The comment is pretty self-explanatory I guess. One of the newest release candidates might fix the issue you're seeing (it makes more checks in the 404 function). You can download from the following URL (just overwrite the existing one):
http://downloads.wordpress.org/plugin/infinite-scroll.2.0b2.110723_RC1.zip

Let me know how it goes :)

That worked, however you need to add a ! in front of the first conditional statement. So it should be:

if (!($paged && $paged > 1) && !have_posts())

Thanks!

Also, is there any plans to add the manual-trigger.js to the WP plugin? I may open a ticket and submit a pull request adding it in if you aren't planning to do it.

@andrewryno andrewryno closed this Aug 3, 2011

Contributor

samcleaver commented Aug 3, 2011

Awesome, I'll make sure that's fixed in the next build! At the moment I'm working on a better interface for the plugin options that will include a selector presets function (with presets for popular themes); once I get that tested and published, I'll definitely look to adding the manual triggering behavior. The new infinite-scroll javascript supports the manual triggering but in a different way than it used it (in 1.5). (We now use "behaviors" that can overwrite parts of the main plugin). I'll keep you posted on any development made on that front :)

Yeah I wound up just copying the manual-trigger.js into my theme files and then adding the right option in the .js file the plugin includes. Works pretty well. Thanks! This plugin/your help really helped me out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment