So I am using a plugin which loads next posts as the user scrolls down in the single.php file. Inside the main php file of the plugin, there is something along the lines of

    // By default, don't query for a specific page of a paged post object.
    // This argument can come from merging self::wp_query() into $query_args above.
    // Since IS is only used on archives, we should always display the first page of any paged content.
    unset( $query_args['page'] );

    $query_args = apply_filters( 'infinite_transporter_query_args', $query_args );

    $single_query = false;

    if( isset( $_REQUEST['postID'] ) && $_REQUEST['postID'] != 0  ) {

        $single_query = true;

        $post_order = apply_filters( 'infinite_transporter_post_order', self::get_settings()->post_order );
        // Post type of initial post
        $post_type = get_post_type( $_REQUEST['postID'] );
        // Allow filtering of initial post type by themes or plugins
        $the_post_type = apply_filters( 'infinite_transporter_post_type', $post_type );
        // Only display posts from the same category as initial post
        $in_same_cat = apply_filters( 'infinite_transporter_in_same_cat', false );

        if( $post_order ) {
            $next_post = $this->infinite_transporter_get_adjacent_post( $_REQUEST['postID_order'], $in_same_cat );
            if( ! $next_post ) {
            $query_args =  array(
                'p' => $next_post->ID,
                'post_type' => $the_post_type,
                'posts_per_page' => 1,
        } else {
            $query_args =  array(
                'posts_per_page' => 1,
                'post_type' => $the_post_type,
                'offset' => $_REQUEST['page'] - 1,
                'post__not_in' => array( $_REQUEST['postID'] ),
                'ignore_sticky_posts' => true

        $query_args = apply_filters( 'single_infinite_transporter_query_args', $query_args );


I want the plugin to load posts from the same category, which I believe is done by $in_same_cat = apply_filters( 'infinite_transporter_in_same_cat', false );. However, I am not sure how to go about implementing this piece of code. If it helps, the plugin is called Infinite Transporter. Any help as to how to implement that filter would be very much appreciated.


Off the top of my head - put this in your functions.php:

add_filter( 'infinite_transporter_in_same_cat', '__return_false' );
| improve this answer | |
  • The second parameter for add_filter must be a function. There are some built in WordPress function to return true or false: __return_false & __return_true, that's why this works. – Nicü Jun 15 '16 at 18:35
  • Gave it a try, doesn't seem to be working. Also tried removing the quotes on return_false. – sadmansh Jun 16 '16 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.