get_categories() gives you an array of WP_Term objects, which has the parent property. This contains the ID of the parent category. Inside your loop you can do a simple comparison to see, if the current iteration category has the specific parent category’s ID or not, and if it does, skip it.
$parent_id = 123; // change to actual term id
foreach( $categories as $category ) {
if ( $parent_id === $category->parent ) {
continue;
}
// rest of the code...
}
Related Posts:
- How to show all posts of the category in wordpress?
- Filtering a custom post type by custom taxonomy in archive template
- Why are posts from custom post type not displayed in “category” archive?
- Get category id from post id of a custom post type
- Displaying category archive of custom post types
- How to let custom post type posts show in standard post archive (like in homepage)?
- Regex problem in an add_rewrite_rule
- How to show related posts by category or custom post type?
- Structuring a product catalogue in WordPress [closed]
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Slug for standard post post_type
- Category page only displaying the posts from a custom type
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- custom taxonomy archive by year
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- How to get the post type from a category id?
- CPT Archive with core Category
- Custom Post Type Archive Page Filtering
- Getting posts under the custom post type ui category
- Show custom post type filtered by category
- Showing posts from different categories and from custom post type
- Add custom post type settings to wordress default posts
- Problem with displaying posts in the CPT category
- Set a checkmark in a category based on a URL-parameter
- Get the category from custom post type
- Custom Post Slug same as Parents Category Slug
- How can I show 1 featured post in a styled element, and the next few below differently styled
- WP the_posts() on single-cars.php get category link
- Create new custom post and post category of same name
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- Custom post types and ‘new WP_Query’
- How to Display Posts From Category Within a Custom Taxonomy?
- Showing custom post type categories in the menu
- Stores category posts in an array
- Restrict category access to specific users/groups. Author always has access
- Post Query not working
- Use post in multiple places on a page with multiple posts
- Archive Template being used instead of Category Template for Custom Post Type
- Menu’s breaking, now showing all page links on site
- Am I mixing up the concept of posts pages and categories?
- Advanced archive url structure (category, tag and date)
- How to achieve a multi-taxomony layout with posts?
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Post category behave like a Post in back office menu
- Save data is post using php front end
- Custom WordPress theme not displaying posts from category
- How to show posts of the same category on a page?
- How to manage a dynamic multi-level page hierearchy system?
- Custom Post By Category
- Adding Custom Post Types to category/tag/author archives breaks header content
- Custom category taxonomy – archive page not showing up
- Change Custom Post Type to Post + Category
- Only show current category post
- How can I generate a list of post-type specific categories?
- Custom Post type archives / categories give 404
- Post Editor: display categories from current post type taxonomy only?
- archive.php can’t find categorized posts
- Custom Post Type used for FAQs Accordion
- Display all post types together
- How can I set up the URL for a category archive for a custom post type?
- Categories in custom post types
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Stop header code from showing in category page?
- show only one category posts in admin
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Display posts of only a certain category in WP Admin section?
- How to get post content by calling ajax?
- Limit widget to a specific registered sidebar
- WP_List_Table Inside Metabox Not Working on Submit
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Display “Post 2 of 4” on single post page?
- Query post types with multiple keys
- Remove Post Page “View Post” Link
- Taxonomy structure of Sport site
- Custom Post Type with static page for archive
- How to display recent / random posts by its category
- How to make post sticky in the admin page?
- Querying Term Posts in Loop
- Which post does a taxonomy term belongs to?
- Add custom field to Posts and sort by it
- How can I list Custom Post Types created with the Types plugin under categories?
- How to filter url on post submission?
- How to controll the Posts post type and general wondering about WP data structure
- If/Else child list for Custom Post Type single template within loop?
- Creating archive like functionality through birectional relationships
- Post template not applying on theme (potentially rendering as Page template)
- Show Custom Post Type based on Category on Archive Page
- $_POST from a Meta Box
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Links Image in “Catalog” Page to Posts
- Structuring 3K pages in WordPress
- Hook only specific post type
- Custom Post Type permalink not working on new posts
- Turn post into simple slideshow
- Custom Post Type or just Post Categories?
- Query multiple post of which one by taxonomy
- How to create a job post by email parsing? [closed]
- Display code if title of the custom post matches title of other post
- Hide load more button if no more post in selected category