WordPress.org

Ready to get started?Download WordPress

Forums

pre_get_posts and pagination (1 post)

  1. MadysonDesigns
    Member
    Posted 1 year ago #

    I can not for the life of me get a modified main query and pagination working together.

    Desired outcome:

    On home template, custom query (with new wp_query) and main query both running. Custom query grabs one post and main query grabs the rest (with offset)

    What I have:

    if ( $query->is_home() && $query->is_main_query() ) { // Run only on the homepage
    	$query->set('offset', 1);
    }

    The offset works correctly only on the main loop on the home page but pagination is broken.

    If I remove the 'is_main_query' function, pagination works correctly but the offset runs on all queries including the wp_query custom one.

    Grabbing the $paged query vars and adding them to the query does not help.

    Thoughts?

Topic Closed

This topic has been closed to new replies.

About this Topic