So the easiest way to do this would be to store the ID of the first post (1)
then in each of your category loops you can use the post__not_in
property like so:
// inside the first loop at the top.
$latest_post_id = get_the_ID();
// WP_Query for fetching each category
$category_query = new WP_Query( [
// other parameters
'post__not_in' => [ $latest_post_id ],
] );
Now to exclude a category in WP_Query
you can use category__not_in
which takes an array of category ID’s. It’s definitely worth checking out the wordpress codex for WP_Query
Related Posts:
- Rearranging posts based on categories
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Display subcategories in dropdown
- Conditional category query breaking?
- Category name for all posts getting assigned to a single random post
- Category post count is not correct
- how tho change number of posts in loop from specific categories
- Querying posts from two different categories while looping inside another loop
- Category slug in in loop always the same?
- Detecting top parent category fails on home page
- WP_Query not looking at child category
- Randomise results from a category page?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Remove child products from woocommerce category page [closed]
- Get a list of commas separated categories inside a loop
- Custom Query to search through categories
- How to query all posts of a specific category, and any other category combination
- is_category in pre_get_posts results in php notices
- How to Check if a Child Category is Being Queried
- How do I get the total number of categories in a list of search results?
- Check if post belongs to any category
- How do I display the posts from a custom post type on a category.php page?
- How to group the loop posts in a particular by author?
- Display products for a category, sorted by post_excerpt
- Exclude category from loop not working
- a-z list, categories and sub categories in loop
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- How to display posts under a specific subcategory of a given category
- get_the_category and echo out link to child-most/deepest category
- Displaying multiple loops based off of category
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Additional featured post on first page
- Show all posts for a specific category/author
- Redirect category to url with /category
- create a page which displays a list of categories title+ short description?
- Enter a variable in the ‘category_name’ parameter
- WordPress Genesis not excluding category from blog
- Query Posts Exclude Entire Category
- query in category.php repeats itself
- Display posts separated by Category in Author’s page
- Remove product category placeholder image (Woocomerce)
- WooCommerce – How to show specific category first-rest of products-specific category last
- Show popular post by category code
- Exclude current post from loop
- how to “not” display new posts with a specific category on the main page?
- How to insert category list into post creation page, and retrieve chosen categories?
- Categories list loop – add separator every 3 categories [closed]
- Trying to get variables in hacked category dropdown
- category__not_in and id values from variable
- Overriding default calendar to show posts from a category
- Do not show sub categories in the loop on archive-product.php
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- Simple way to style posts of a single category differently in the loop and in single
- Two Sections on Woocommerce Catergory Page [closed]
- Getting the Most Recent Posts from Multiple Categories
- Hide a category of posts from main blog, and only show in category view
- Display category title and three latest post inside the category
- Have posts that belong to multiple categories, exclude some categories from homepage
- Show multiple categories in query using redux framework variable
- Get the ID of the current post’s child category
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Get categories of queried posts
- How to display posts from specific category using get_option function?
- Display post thumbnail for specific category outside the loop
- Filter Category Loop Dynamically
- SQL query to get posts from multiple categories but not in a category
- the_category() doesn’t working in wp_query loop
- Category sticky latest
- Exclude posts without category from loop
- excude a specidic category from showing in the “relative posts”
- Show the number of the post
- How to create category filter on a blog like on the site below?
- How can I order all subcategories alphabetical independent of the parent categories?
- Template category.php with page (no posts)
- How to create a category loop on my blog (ACF Plugin)
- Displaying Category in sidebar post widget but not in the loop on home
- Issue with WordPress category search
- Loop doesn’t work
- How to get posts from many categories using WP_Query
- Display Taxonomies in loop with template args
- How to loop through a custom field for each post, & display?
- show category name before first posts in each category
- Loop within category’s posts
- show posts found in multiple categories via category_name query string?
- Loop through posts of CatA and store value of CatB in separate array
- How to add an empty entry to masonry?
- Loops in category description
- Several loop in search result
- Pages, Categories, and working with someone else’s code
- how to get number of posts in a category on a specific date
- Show posted on date only for posts in a certain category
- 2 loops in archive.php (one for each category)
- Displaying posts by year
- Multiple Categories under one URL, where ‘Front Page’ is used already
- Using pagination with multiple loops causes it to break
- How to create a custom loop ordered by Categories on a Page Template?
- How can I implement pagination on custom category page?
- Order Categories by Character Count
- Get categories by title descendant