For reference of other I’ve managed to get help with this with help from wordpress support forums.
You can specify a second parameter in get_terms to exclude specific term IDs:
$term_args = array( ‘exclude’ => array(5, 8) );
$custom_terms = get_terms(‘service_categories’, $term_args);In the case above, we’re excluding terms with ID 5 and 8.
Reference:
https://wordpress.org/support/topic/excluding-top-level-from-taxonomy-and-post-loop?replies=3
I added the code above before the foreach and it worked perfectly.
Related Posts:
- Include custom taxonomy term in search
- List all the tags from a custom post type
- Are custom post types lost when the theme is changed?
- How to Make a Separate RSS Feed for Each Custom Post Type
- Get terms that contain posts that in turn belong to other terms?
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- custom post type taxonomies UI radiobuttons not checkboxes
- Custom Post Type Archive Template
- Order posts by (hierarchical custom) taxonomy terms and term children
- Filter get_categories() for taxonomy term in WordPress
- Custom search for custom post type, custom meta and search fields
- Posts per Page on custom Taxonomy Template
- Display CPT taxonomies as an archive page
- How do I list terms of a custom taxonomy at i.e. domain.com/brands/
- Permalink Structure problem with cpt and custom taxonomy
- Taxonomy-{taxnonomy}.php is not working
- Auto Draft Specific Categories Posts after a certain number of Days
- Custom Taxonomy 404
- Custom post type permalinks giving 404s
- Custom Post Type Query multiple Taxonomy Terms
- How to add custom fields to admin UI and REST API response?
- Custom Post Type: Linking Terms to show Count
- WordPress tax_input only if logged in
- Taxonomy Url with Custom post type prefix re-write rule
- How to filter the taxonomy terms based on another taxonomy term
- How to sync tags between posts that are linked through Posts 2 Posts?
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Combining custom post type and post category
- how can i get posts from custom post type particular taxonomy category
- Conditionally custom post type url rewrite
- get_the_terms return only last term
- How do I get array of types associated with a taxonomy?
- Root slug of taxonomy returning 404
- wp_get_post_terms on custom post type with custom taxonomies returning an empty array
- Pagination for Custom Taxonomy Page [duplicate]
- get_category_parents for custom post type taxonomy
- Custom loop with multiple taxonomy queries
- Hide post navigation if current post is in a category with only one post
- Setting up taxonomy to relate various custom post types – advice on structuring?
- I want to change the word “Tags” in WordPress to something else, but how?
- What is the best practice for displaying my plugin content in themes?
- Set post terms for multiple posts
- Get terms that contain posts that in turn belong to other terms?
- Sitemap generation
- Archive for a Taxonomy of a Custom Post type
- Pagination Not Working for Custom Taxonomy with Custom Query – 404 Error
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Main query not querying any posts in custom taxonomy template
- Shared terms between taxonomies
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Custom sidebar for custom post type
- Show category and tag link as a submenu under custom post type submenu
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Add filter to Admin list for all custom post types by their custom taxonomies
- Single.php for Custom Post Type > Taxonomy > Term
- Add the custom post term to the custom post title
- Display 3 recent posts from one taxonomy
- Display next 3 posts based on custom taxonomy
- Displaying custom taxonomy menu in custom post type archive
- Custom post types templates
- prevent sub categories to show up
- Display latest post of taxonomy
- Custom post type category link redirecting to 404 page
- Custom post type and multi taxonomies + customize url
- Archive page URL for custom taxonomy and post type
- Custom Post Type Archive Page showing as 404
- Custom taxonomy terms hierarchical navigation
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- What is the best way to structure posts for the same event happening in different years?
- WordPress Custom Taxonomy – If not parent term
- Dynamically Adding Posts of Post Type to A List
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- I cannot display custom posts in custom taxonomy
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Custom taxonomy with custom post type template not showing
- Loop to display parent categories in custom taxonomy
- One-Time Script TimeOut for Large Data
- Not Able to List CPT Based on Taxonomy Term
- Filter Term By Parent Term – Custom Post Type
- CPT Efficient way to display posts from different categories with custom query
- Associate custom categories to different user IDs
- How to create default taxonomy term for a custom post type? [duplicate]
- Extensive search filtering and results->PDF in the front-end
- redirect old post type url to new structure url
- Post data in separate divs with incrementing class using WP_Query
- Custom Taxonomy List, Selection floats to top
- Get term_id for each instance of custom taxonomy
- Customize category URL
- Permalink Trouble with Custom Post Type
- How to internationalize the sub menu name “categories” in Custom post type?
- Custom Post Types and Taxonomies
- install.php Custom Taxonomy Term not being added to custom post
- How to retrieve taxonomy terms of the current custom post?
- Custom post type with new taxonomy [duplicate]
- Custom post type / Filter by letter
- trying to display custom post type with custom taxonomy value by shortcode can’t works [closed]