I think you could do something like this:
$categories = get_the_category();
$displayed_category_id = 1; // set this to the category ID you want to show
$output="";
if($categories){
foreach($categories as $category) {
if ( $displayed_category_id == $category->term_id) {
$output .= '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>';
}
}
echo $output;
}
It might not be the most efficient code (and it’s untested) but it should work…?
You could swap out the slug or category name pretty easily if ID isn’t the key you’d like to use. G’luck!
Related Posts:
- Exclude category from category archive
- Better way to exclude category output for post/pages?
- Exclude Categories from wp_list_categories()
- List post wit the same category but exclude parent
- Get first category only and excluding one
- How to define category ID in an array?
- exclude category from get_posts?
- Exclude the category from the WordPress loop
- Exclude certain category from latest updates
- How to add the category ID to admin page
- Exclude categories from Loop, queries, widgets, post navigation
- List posts by category exclude current post
- wp_list_categories exclude not working
- How to filter by category in REST API, excluding posts also in other category term?
- Exclude Tags from get_the_tags
- Excluding a category from next and previous post links
- is there a quick way to hide category from everywhere?
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- Add category to custom post type automatically, using category slug
- How to exclude categories from recent posts, recent comments & category widgets?
- Exclude a category from the filed under list only on some templates
- On Category page, How can I get the category ID?
- How to set post expiration date and time and move the page to archive after expiration [closed]
- How to exclude posts from a category when using this particular format
- How to get category URL with the slug?
- Exclude category from Tag Template
- How to view WordPress’ default category IDs?
- exclude post from displaying in loop if it is in a category, but not in many categories
- I need to create a search form that will display search results from specific category
- Exclude Posts From Specific Category from Next and Previous post links
- Query Posts Exclude Entire Category
- exclude categories from search results
- Exclude category from fucntion
- WordPress category widget only show categories with children
- Exclude Category filter from Portfolio section
- Style category link depending on category ID
- Multiple arrays in post__not_in parameter
- Excluding posts not working
- wp_list_pages() exclude category
- Include posts from some categories while excluding from others
- Loop doesn’t exclude the specified category in home page
- How do I remove a category from a wordpress loop>
- Exclude category from query
- Functions.php: Exclude Category from “Blog”
- Exclude Category ID in function
- Woocommerce filter function not updating
- How can I exclude a specific ID from this line of code?
- Edit tag_id in category pages of dashboard
- How to get post with slug and exclude categories
- wp_list_categories not excluing multiple ids
- Exclude post category in a blog page
- How to get selected taxonomy or category ID if using custom walker?
- How to exclude posts from category posts count
- Exclude category from foreach loop
- Have posts that belong to multiple categories, exclude some categories from homepage
- Are post, page and category IDs unique to each other?
- Exclude all subcategories in the_category (post)
- Exclude some categories from the post page
- Exclude category from get_the_category
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- Don’t execute function on specific posts
- WooCommerce Hiding A Certain Category From Being Displayed On Single Product
- using pre_get_posts to exclude
- Check is category parent with ids from the childs – get_term_children
- Homepage custom recent news
- problems exluding categories
- Exclude the category in WordPress
- How can I exclude a category from the main loop with the category name & not ID?
- User level categories
- Exclude category from drop down list form
- Disable the link on certain pages
- exclude certain categories form archive widget
- Exclude Woocommerce Product Category From Sitemap
- Custom Post Type with Sequence ID
- How to get an array of pages ID by some page’s slug and all its children pages in get_posts() function?
- How to remove an item from a custom Walker_Nav_Menu
- Exclude a category and post_type from wp_query
- Exclude category and post from loop in custom category.php
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Excluding category from post navigation in WordPress?
- post__in and tag__not_in conflict
- Exclude category from WP_Query args not working
- Displaying Category in sidebar post widget but not in the loop on home
- How to exclude one category
- How to exclude a category in the following Code?
- Store All Post Categories In Array
- Category menu that filters out empty categories
- trouble with my loop
- Problems with explode [closed]
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- How to have a category not show up in query post with page panigation?
- Customize category query in widget
- Exclude a ‘portfolio’ custom category?
- Call function on a single page
- Excluding cateory not working on my site. how to solve this? [closed]
- hide particular category post from front page only [closed]
- View post with specific category id and name which I selected in the backend (drop-down option)
- Exclude a category ID from the following function
- How do I get the current edit page ID in the admin?