You can get all of the parents of an object via get_ancestors
–
$term_id = 42;
$your_taxonomy = 'sometax';
$parents = get_ancestors( $term_id, $your_taxonomy );
Related Posts:
- Archive page showing nothing – issue with WordPress Hierarchy?
- How to make a list that displays the top level subpages, and any subpages or siblings off of the current page
- How do i get the direct neighbor in a hierarchy
- Product subcat with duplicate name of a subcat of another cat gets the category name in the slug
- HowTo preserve page hierarchy with wp_list_pages()?
- Automatically Query Parent Taxonomy
- Will renaming a `content.php` file cause any problems?
- (get_post_ancestors == 2) is returning true on 1 as well?
- Get terms in hierarchical taxonomy
- Hierarchical types and page size problem in heavy sites
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to show a hierarchical terms list?
- The Difference Between Hierarchical and Non-Hierarchical Taxonomies?
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How to set parent-child relationship between differents custom post types
- Modify Taxonomy pages to exclude items in child taxonomies
- Get the the top-level parent of a custom taxonomy term
- How can I allow commas in tag names?
- Integrating a custom post type into a page hierarchy
- Taxonomy: Why ‘with_front’ => false DOES NOT WORK?
- Nested custom post types with permalinks
- Custom taxonomy, get_the_terms, listing in order of parent > child
- How to add images to taxonomies?
- Change custom post type to hierarchical after being registered
- Get url of product’s images (woocommerce)
- How to Check if a Page Exists by URL?
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Custom Taxonomy and Tax_Query
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Get top level page parent title
- How To Limit Hierarchical Pages Depth (For Custom Post Types) To Children Only
- Determine Term depth
- page title, parent tilte and grand parent title
- How to add a custom metabox to the Menu Management admin screen?
- Using multiple taxonomies to sort Custom Posts
- Assign posts to taxonomy terms instead of the taxonomy terms to posts?
- What is the best page ordering plugin that works well with WPML? [closed]
- How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
- Display a list of child posts on parent posts of a custom post type
- Custom Post Type as Page parent
- Show current navigation path from menu
- How to handle a hierarchy with custom post types
- WordPress admin screen very slow / timing out when editing or adding a new page/custom post
- Is it possible to add custom fields to a WooCommerce attribute term? [closed]
- Different template for subcategories
- Custom Taxonomy Tree view
- Can I have Post Types under other Post Types in Admin menu?
- wp_get_object_terms() to get a list of all the terms attached to all the posts in the current query
- set a CPT as parent of a page
- Hierachical Custom post types permalinks not working
- Better way to enforce category hierarchy in post_categories_metabox?
- Taxonomy/category hierarchy lost when editing posts [closed]
- How to enable hierarchical permalinks for hierarchical taxonomies
- Disable block from editor based on post type
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Get taxonomy name of current post
- Exclude from search all custom posts which are NOT in a taxonomy term
- WP 5.8 “Query Loop” block: where to place custom query?
- Categories’ hierarchy in URL
- WP_query taxonomy + get all posts with two terms from same taxonomy
- Determine if Term has Grandparent/Great-Grandparent
- Custom Taxonomy Relationship (ex: plant classification)
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- Custom SQL Query on Custom Post Type. Order by Taxonomy?
- Child pages on hierarchical Custom Post Types 404s
- How can I combine posts of different types in one hierarchy?
- Does the ‘WordPress Order’ feature, within the WordPress Dashboard, have any impact on site architecture?
- Easy way to process search results before displaying
- SQL Statement generated by WP_Query not producing expected results
- Custom Post Type ‘hierarchical’ Help!
- Is there any difference between post in child term and child & parent terms?
- How to check if last uri segment is a custom post type or taxonomy term?
- How to only show posts on last child category
- Custom archive page based on array of categories and tags
- Custom permalinks – post type – hierarchical taxonomy’s
- How to show term-specific post list, without posts associated with child terms?
- How to fix a double slash in custom permalinks with hierarchical taxonomy’s?
- How to show only parents subpages of current page item in vertical menu?
- How to reduce the database query-es
- Permalinks for WooCommerce Categories and Subcategories
- URL Design for Sub-Posts?
- How to include parent terms in hierarchical taxonomy URLs?
- How to query for posts (in hierarchical custom post type) that have children?
- Multiple loops on page only show taxonomy name of first loop
- Get parent page/menu id of current post
- Combine multiple custom user taxonomy in single url
- How to set hierarchical terms to a post using wp_set_object_terms
- Help building array hierarchically with taxonomies (to get posts)
- How to Create Hierarchical Directory for Nation Wide Mental Health Services
- Hierarchical display of custom taxonomy
- Getting taxonomy terms used by custom post type
- Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links
- How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero
- Advanced Tax Query
- Categories lose hierarchy order once assigned to post
- how to automatically generate hierarchical menus from hierarchy of pages?
- wp_list_pages doesn’t work in hierarchical custom post type
- WP_Query use for a filter with multiple Taxonomies and Terms
- tax_query shows no results if nothing is selected
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy