[resolved] query vars changed via pre_get_posts not respected by infinite scroll (2 posts)

  1. helgatheviking
    Posted 3 years ago #

    posted on github, reposting here:

    i've modified my main query to add a second post type

    function add_external_videos_to_query( $query ) {
        if ( is_main_query() && is_home() )
            set_query_var ( 'post_type', array('post','external-videos') );
    add_action( 'pre_get_posts', 'add_external_videos_to_query' );

    without the infinite scroll plugin enabled (Version 2.0b2.120226) visiting pages 2, 3, etc show mixed posts of both post type as expected. however, when using infinite scroll, posts of other post types do not appear in the added content.

    https://github.com/paulirish/infinite-scroll/issues/77 implies that the pre_get_posts filter should work fine w/ infinite scroll, but i am not experiencing 404s on the paged pages, i'm just not seeing the second post type... in this case 'external-videos'.

    infinite scroll goes to the next page and scrapes the data from a specific div, but it seems like the pre_get_posts filter is not being run. i

    what hook does the infinite scroll run on? what logic should be used so that the infinite scroll requests also run the filter?


  2. helgatheviking
    Posted 3 years ago #

    never mind:

    the solution was mentioned already. the CSS selector was not the same for both types of posts.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Infinite-Scroll
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic