It helps to write problems down.
After I haven’t used pre_get_posts
extensively, I focused too much on that area for the cause, but it was the if
clause.
Changed to
if ( ! is_admin() && $query->is_main_query() && ! is_post_type_archive( 'cpt' ) ) {
return $query;
}
elseif ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'cpt' ) ) { // on is_post_type_archive( 'cpt' )
$query->set( 'offset', '1' );
return $query;
}
else {
return $query;
}
Everything is working fine. I like pre_get_posts
.
Related Posts:
- Offset Page Loops and Pagination
- When to use WP_query(), query_posts() and pre_get_posts
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- What is “main query”? [duplicate]
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- How to uniquely identify queries?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- Changing Posts Per Page and offset with pre_get_posts
- Slow SQL_CALC_FOUND_ROWS Query
- “pre_get_posts” firing on every query
- RSS feed with specific keyword
- Using is_main_query to select custom post type on certain page
- Multiple orderby parameters in pre_get_posts() action
- SQL Statement generated by WP_Query not producing expected results
- How to adjust found_posts so that it accounts for offset and pagination
- Sorting Posts by custom field
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Recommended way to drop a pending query (in pre_get_posts)?
- Single page theme that uses pages for the content
- WP Query with offset breaks wp_pagenavi or any pagination
- WordPress custom search form with pre_get_posts not work
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Exclude first 5 posts of specific categories in the main loop
- order by multiple meta keys in pre_get_posts
- Custom query, works, but I get a “Notice: Undefined offset: 0…”
- How to sort posts in admin by titles with dd.mm.yyyy format?
- WP_Tax_Query with post_tag not working
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- How to Modify Taxonomy Archive Page with Search Parameter?
- Using pre_get_posts on a specific core/query block
- Searching through different categories on different pages code is not working
- How to display future posts – modified query still yields 404
- pre_get_posts filter meta_query without conflicting existing meta_query
- Including only current user’s posts in search
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- How to change posts order on Category and Tag archives?
- Formulate a url to show posts with both taxonomy terms
- My Main Query Modification is Messing up my dynamic main – why?
- pre_get_posts Remove tax_query Completely
- pre_get_posts order by not working
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to choose between hooking into per_get_posts or into parse_query
- How to use offset in WP_Query
- Store sticky post’s ids in a transient
- How to change main query based on post meta
- How can I fix: “Notice: Undefined offset: 0”?
- new WP_Query to get max price meta value not working
- Display posts from only one post form in custom query and exclude in main query
- Show Sticky Post at the top but do not show again in the loop?
- Complex WP SQL Query
- Using meta_query with multiple keys and compare values
- Can I set my WP_Query to be a Main Query?
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Show scheduled posts in main loop but not in WP_Query?
- hide custom post types with specific meta key ON admin backend
- WP_Query ignoring tax_query when is_singular
- Applying posts_clauses filter to specific queries only
- Help ordering Post loop by two meta values
- Filtering out child category posts from parent category archive not working
- Order ascending is ignored in meta query?
- New WP_Query calls Pre_get_posts filter twice
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- Shouldn’t I be able to modify the main query by this filter?
- How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?
- using pre_get_posts for search results not found
- Hide elements outside loop based on query
- How do I rewrite this loop as a new WP_Query style-loop?
- WP_Query arguments order
- Woocommerce – exclude only older out-of-stock items
- WP Query – order posts by meta field first and then order the rest
- pre_get_posts – Trying to get property of non-object warning
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- queried_object using pre_get_posts gets notices and warning
- date_query in pre_get_posts out of memory
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Apply query arguments after the nth post
- AJAX Breaking Offset Argument In WP Query
- WP_Query – How to get all posts of specific days of week by custom field date?
- Page navigation doesn’t seem to work when I add offset?
- Multiple meta_key ordering with pre_get_posts
- WP_Query offset is returning post from prevois loop
- Sorting search results with custom dropdown
- pre_get_posts – editing query, tax_query
- Child pages not affected by orderby
- Offset WP_Query by negative 1
- How to apply pre_get_posts to a custom query?
- tax_query in pre_get_posts