You need to get the post ids from the original main query and exclude them. Then you should remove your offset from your custom query. That should do the trick. Random ordering basically ignores the offset parameter, so you need to explicitely remove the posts from the query to exclude them
You can use wp_list_pluck()
to get an array of post ids from the main query object (using $wp_query->posts
)
$posts_ids = wp_list_pluck( $wp_query->posts, 'ID' );
You then need to pass this to your query arguments as the post__not_in
parameter
'post__not_in' => $posts_ids,
Related Posts:
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- How to adjust found_posts so that it accounts for offset and pagination
- Add inline HTML to posts published within last 24hrs
- meta_query not working properly
- WP Query with offset breaks wp_pagenavi or any pagination
- Show one post per author and limit query to 8 posts
- 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
- Custom query, works, but I get a “Notice: Undefined offset: 0…”
- Order posts by meta value and Date
- Offset Page Loops and Pagination
- How to use offset in WP_Query
- How can I fix: “Notice: Undefined offset: 0”?
- WP_Query, pre_get_posts and offset
- Reset WordPress Post Query to default
- How do I rewrite this loop as a new WP_Query style-loop?
- WP_Query arguments order
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Apply query arguments after the nth post
- 2 column recent post query not respecting float right [closed]
- AJAX Breaking Offset Argument In WP Query
- Page navigation doesn’t seem to work when I add offset?
- WP_Query offset is returning post from prevois loop
- Display recent posts on another site
- Offset WP_Query by negative 1
- How to add a recent post function to a text widget I created for practice?
- setting offset to category number in archive page
- Using something else instead of using 9 wp_query
- date_query problem
- Featured Image as Background with Offset
- WordPress WP_Query offset parameter not working with search parameter
- Using a custom WP_Query with get_template_part loop
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to make WP_Query ‘post__in’ accept an array?
- WP_QUERY Get posts by category and similar name (Like)
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Is it possible to wrap Geo Location search around WP_Query?
- Merging multiple wp_query objects
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Using custom meta_query with relation not working as expected
- Only show first post to match certain criteria within WP_Query
- What is an efficient way to query based on post_meta?
- Pagination wont work with search results template [duplicate]
- Pagination Not working on Home Page with 2 Query
- WP_Query in a shortcode
- Sort by meta key on archive page
- Get post ID’s from one query and exclude from another
- What are the differences between “Latest Posts” and “Static Page”?
- Retrieve or Query Pages by ID
- WordPress Query is taking more then 20 second and stuck on creating index
- Modifying raw $_POST data early in the lifecycle
- Searching through different categories on different pages code is not working
- Difficulty with rewrite rules
- Show selected images on top in Media Manager
- How to make this WP_Query run faster on a WordPress website?
- Complex date range with WP_Query and BETWEEN
- Attachment changing page’s permalink – $post not resetting?
- showing all search result in one template
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Make (post) query a clickable link
- How can I filter by slug depending on language selection
- Ajax WP_Query reutrns no results on author.php
- Large AND OR query timing out
- WP_query wp_posts_counts returns only count of admin and not users
- Categorising search results based on Custom Fields
- get_post_meta slowing down my page load (in a plugin)
- wp_query not working with post_type
- WP_Query posts with comments only
- Default permalink structure causing Notice: Undefined property: WP_Query::$post
- How to check the array values, what WP_Query has brought to me?
- How to Order a list of taxonomies? orderby?
- Get posts that do not have the same tags as current
- queried_object using pre_get_posts gets notices and warning
- post_parent don’t work and return 0 page
- Exclude a Woocommerce product from WP_Query
- WP_QUERY wrong ammount of posts
- Expecting statement error from php loop using ACF plugin
- Get specific ACF key and value from all posts – no access to DB
- Query only displays one page_id
- How to exclude a category name from showing?
- I am officially missing something about transient posts
- Register Taxonomy – What is `query_var`?
- Get Post ID as a separate RSS feed item
- how to retrieve WP_Query without ordering by date [duplicate]
- Related posts by current posts child category
- Block internal search queries with pre_get_posts and regex rules
- Is it possible to give a classname to specific comments in the WordPress admin?
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- How to upload 3 attachments to current post?
- WP_Query for posts that have postmeta assigned to a taxonomy
- Help displaying related categories
- How to make a wordpress loop file that displays posts based on certain conditions
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- How do I display posts with specific value in a custom field into my loop?
- Orderby Meta Value and Query from Meta Query
- WP Query to order posts by multiple meta fields
- Order by multiple meta keys on wordpress
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- I want to capture the last day’s (today) posts in a category in the numbered order in acf