You can use get_ancestors:
<?php
if ( $term_ids = get_ancestors( get_queried_object_id(), 'category', 'taxonomy' ) ) {
$crumbs = [];
foreach ( $term_ids as $term_id ) {
$term = get_term( $term_id, 'category' );
if ( $term && ! is_wp_error( $term ) ) {
$crumbs[] = sprintf( '<a href="https://wordpress.stackexchange.com/questions/225528/%s">%s</a>', esc_url( get_term_link( $term ) ), esc_html( $term->name ) );
}
}
echo implode( ' > ', array_reverse( $crumbs ) );
}
Related Posts:
- How to show only one category in breadcrumb navigation
- Multiple category selection in post, shows less important category in breadcrumb
- Can I prioritize post categories for choice for breadcrumb trail?
- Category name as page title
- Breadcrumbs and Categories
- filter single_cat_title avoiding the breadcrumbs
- Only show sub-category
- Categories Not Showing in breadcrumbs in posts
- Main menu not appearing on category pages
- Multisite blog converting categories to subdomains
- Using URL parameters, list posts from category and custom taxonomy
- Display posts links from a category group by year
- List categories for author: list_categories function inside list_authors function
- Hide a certain category name without removing it?
- strip last comma from get_the_category
- Custom Query to search through categories
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Get sticky post from category?
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Remove word “Category” from WooCommerce product page [closed]
- Get a list of Terms for a specific category
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- How Do I Merge Categories With phpMyAdmin
- Display name of the last child category
- Edit the markup of categories list
- Show category children, one level
- Viewing category pages without the word ‘category’ in URL
- How to view WordPress’ default category IDs?
- Random taxonomy category list
- how to change template?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Show all posts for a specific category/author
- Hard coded main navigation
- Resort get_categories
- Display posts separated by Category in Author’s page
- One Specific Category To Permalink
- The arrangement of categories always change while posting article
- Woocommerce custom category page with pagination [closed]
- Exclude current post from loop
- Exclude categories from wp_list_categories by category slug
- Can’t delete a category in WordPress
- WordPress Categories in data-groups
- Nicer URL for viewing category of posts?
- Get Categories Where Taxonomy Equals ‘n’
- How to access deleted term inside delete_product_cat action
- How to order get_categories() in the same order as the menu?
- Remove Archive | from Categories
- Showing Categories for Page Edit – without plugin
- Difference between wp_list_categories and get_categories
- Show different menu on each woocommerce category page
- Have posts that belong to multiple categories, exclude some categories from homepage
- Only first category!
- How could I write a get_categories_by_year() function?
- How to add icon over specific thumb
- add_settings_field (exclude categories->reading) wp_category_checklist
- Retrieve post tags from from main wp_query
- Listing Post Categories on Home Page
- Get posts in a subcategory of a chosen parent
- How can I only display links from a child category
- Category Template – Show Last Entry as Featured
- How to add meta description, keywords, custom title to a category template
- User level categories
- Exclude category from drop down list form
- How to set the same base url for two different taxonomies?
- Hide category name but show posts
- Count how many posts have a specified tag AND category
- Parent Category and Subcategory default text generated with category
- Post List by category and under custom taxonomy
- How to create a table with counts of category combinations?
- How to get the_category(‘, ‘) with link “title” attribute
- product_cat image url from database
- Multiple if statements with else for get_the_category [closed]
- Balance Tags to the_content Words Length
- How to create template for children category?
- Using a template page parent breaks page
- Setting category for post as default
- Query post only from categories that have subcategories
- How to get the link of all categories
- Show parent category if there is no subcategory
- foreach,having wp_query inside, breaks after showing one result
- Display a category name automatically using code in the functions.php file
- Removing categories, Comments etc from posts?
- Include Category Description in search result
- Problem importing categories and sub-categories
- Show parent-child relationship for categories in the wordpress admin
- How to assign different categories to pages in wordpress?
- how to ask if in two categorys inside if
- All post of child category not in top category
- How to add a tag above a category post that displays the category name in WordPress
- Woocommerce – Display product category of product in Orders page
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- Add an Exclusive or featured tag line to article titles
- How to list out post category name and description in page
- Print child category slug nicename
- How to link ACF relationship field to the new Query block in Full Site Editing
- Order Categories by Character Count
- How to remove the category from the url only for a specific category of articles on wordpress
- Is there a standard “Archive” block that shows ALL posts from a specified category?