Assuming that when you are on the “page” sub_category_1
you’re looking at a standard archive for that term, you can do this…
The main query is already for the posts in sub_category_1
so get a list of their IDs:
global $wp_query;
$post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
Then you simply need to get a list of the terms from brand
which are assigned to those posts:
$terms = get_terms( array(
'taxonomy' => 'brand',
'object_ids' => $post_ids,
) );
$terms
will be an array of the WP_Term
objects.
Related Posts:
- Custom post type single-{custom}.php not working
- How to build a complex page structure
- Limit users by custom taxonomy and user roles
- Generate Shortcodes by Taxonomy
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Displaying a custom post types custom taxonomy value?
- What template files do I need to customise custom-category-term-links rather than fall back on archive.php?
- Help need making decision. Ads rotating site on wordpress
- custom taxonamy and post type
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- Display a grid of taxonomy terms at root taxonomy page
- How to have this permalink structure: post_type/postname/custom_inner_page
- How to produce a sub-page-system in WordPress
- how to get this tax_query working?
- Show Taxonomies with admin area for custom post type?
- Include custom post type custom taxonomies in Categories widget
- How can I tell if I’m on a custom post type archive page?
- Getting Same Description in All the Custom Taxonomy Posts
- Error 404 change permalink term custom term taxonomy
- Custom post type 404 category page
- How to search through all child taxonomies using WP_Query?
- I have a random letter appearing before my content. Where to start looking for the cause?
- Custom Post Taxonomy Template Not Loading Properly
- How to display only child category post in related posts in custom post type?
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Help with Multi Level Category Archive Page
- Custom post type with custom taxonomy permalinks
- Custom taxonomy page template
- show custom taxonomies in hierarchy
- How to Create Custom Post Type with Multiple Color Options?
- Custom post type and custom taxonomy archive inaccessible
- Apply custom names for generic custom taxonomy name?
- How to get all taxonomies of a post type?
- Permalinks: custom post type -> custom taxonomy -> post
- How to Add Tags to Custom Post Type?
- Change permalinks for posts but not for custom post types
- Efficient Taxonomy Intersection
- Assign single template to multiple custom post types?
- Set relationship between custom_post_types
- How to list custom taxonomy categories?
- clients list using wordpress
- Custom taxonomy query for a custom post type
- Extend walker class with custom post types [closed]
- How to do a custom bookmarks post type?
- Custom permalinks – post type – hierarchical taxonomy’s
- Taxonomy list. Order by a specific custom post type count
- Rewrite CPT slug with two taxonomy slug instead of one
- How to display Custom Taxonomy of Custom post type
- associate custom post type with tags with specific pages
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Custom Taxonomy breaking pages permalinks
- taxonomy template for custom post type the same as the archive
- Get categories and descriptions from custom post type
- Problem with custom post types, taxonomy and permalinks
- How to create new category for custom post type?
- Repeating posts when paginating random posts
- Query/list all terms and their custom post count
- Remove url rewrites for registered taxonomies
- How can I make a custom post type sticky?
- Get Taxonomy Term Title by it’s URL
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Group CPT posts by custom taxonomy
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- Building a Treatments Page, What Do I Use?
- Create more category hierarchical depth for custom post type/taxonomy plugin (widget)
- How do I share categories across multiple post types?
- Migrating a taxonomy’s tags to the native category
- How to check if post/page or taxonomy post is published by admin
- Custom taxonomy or custom page templates?
- Custom Post Type Advanced Slug
- filter by custom taxonomy using ajax
- Should putting custom code in functions.php or created the plugins [duplicate]
- List child categories from parent category on custom taxonomy page
- Create a custom taxonomy template that loops through child categories in term order?
- Custom Post Types and Complex Content Hierarchy
- Loop all post on single.php
- How to display custom taxonomy term specific post?
- Changing permalink of default Post with custom post
- get_queried_object not work in taxonomy page
- wp_insert_post deleting previous post custom meta
- How to create a permalink structure with custom taxonomies and custom post types
- How to get all posts related to a taxonomy?
- Custom post types not displaying per category
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Hierarchical taxonomy in permalink structure
- Can I create a taxonomy term that mirrors the name of a new custom post?
- Rewrite for custom type and custom taxonomy
- Why won’t this rewrite rule work?
- Archive.php is not displaying tags
- How to not have the items of the subtaxonomy within the parent taxonomy
- How to save an integer as taxonomy term?
- Sort custom post type items by taxonomy description
- Get custom post type parent category
- How can i change url structure of cpt like this?
- How to create custom page templates with default page layout framework?
- Create a hierarchical list of posts that’s grouped and nested by category