If you use wp_list_categories
(see Codex), it automatically adds the classes cat-item
,cat-item-{ID}
and (to the current category being viewed) current-cat
. (It also adds current-cat-parent
to the parent of the current category).
This should be enough to style any particular category a certain way, and style the current category a particlar way.
However, you can obtain the current category being viewed by, in your category template file, using:
$term = get_queried_object();
The current category’s slug is given by $term->slug
. This would allow you to add a certain styling to the current category (the exact details of how to do that would depend on how you were displaying the category links).
Related Posts:
- How to show only one category in breadcrumb navigation
- Get rid of WordPress category, tag and author archives?
- How to add the category ID to admin page
- Reflect nested categories in appearance > menus
- How to create a widgetized sidebar for every category dynamically?
- Only show category to certain user levels without plugin
- Category menu item and its last 10 posts as sub-menu
- List Categories of the Parent Category of the Current Category
- Is there a function to cause empty categories not to show in menus?
- Assign different category colours to different categories in the main menu
- Keep active class in post page
- Auto add pages to category menu
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- wp_list_categories, Add class to all list items with children
- Remove “Parent” Selection When Adding/Editing Categories?
- Check is category parent or not from its ID
- Custom Category/Subcategory structure
- How to show in search results posts with a particular tag in a particular category?
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- Add a specific category at a specific place to the menu that uses wp_list_pages
- If category is in parent category?
- Multiple menu items highlighted
- wp_nav_menu not highlighting the current category when viewing a single post
- If in category to be inside of a function
- Rename Default Category (Uncategorized) Via a Function
- Show Different Custom Menu on Different Category Pages
- Open subcategories in submenu on click in primary menu
- How to add Categories to the top menu of the website?
- Looking for the best solution to build this Blog structure? Picture attached?
- Nav menu category links not showing
- Show number of articles in menu
- Getting URL of archive (category) page
- Automatically adding categories and authors in custom menu?
- Hard coded main navigation
- Highlight wp_nav_menu when category is selected
- Class active for Archive link – looped out
- Menus don’t work after 4.4 [closed]
- Create menu / submenu from category subcategory and posts
- Categories as main menu items and subcategories as nested lists
- wp_list_categories in in nav_menu
- Different menu navigation per category
- WP admin broken. Not saving catgories or adding categories to menu
- Creating Category Specific menus
- Custom Walker for wp_list_categories
- Redirect to another page using contact form 7? [closed]
- Create menu locations for each category in wordpress
- Random Featured Image Based on Category
- Building Menu from Woocommerce Product Categories
- Show subcategories on a parent category page
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- add slug beside name in Admin Category Checklists
- Give Children Unique ID’s
- WordPress list categories dropdown with parent-child relation and child under it’s parent
- List a maximum of ‘x’ product categories with qty of ‘y’ in each column
- Searching for a category returns nothing if category is empty
- function query_posts disabling current_page_menu class
- How to use wp_list_categories with plugin category?
- Theme for subcategories
- Multiple categories for one menu item?
- How to get category id’s which are added in main menu?
- Link from navbar to categories
- Pagination doesn’t work on multiple categories
- Theme modification for custom category menus
- Change appearance based on category but post is in two main categories
- Redirect depending on category chosen
- How to load several hierarchical categories from functions.php
- Change Default Content when Creating a Post based on Previous Category Choice
- How to add a custom thumbnail size for a specific category?
- wp_nav_menu not appearing correctly on category page
- wp_list_pages() not showing on posts
- Custom menu with categories and tags
- create function to call category name and slug
- Different size video display for category page (smaller) & detail page (larger)
- Global navigation in multisite: problem with categories
- How to automatically generate custom menu item from categories?
- WP-CLI Add category as menu item main-menu
- Categories are not available AT ALL under Menus
- ADD DYNAMIC attribute for category to accordion
- How to add all subcategories as submenu in WordPress menu
- Display menu in category and sub category
- WordPress category title not update in navigation menu
- Function add class to second menu specific items if the page has a certain category
- Show alternative menu based on page template AND post category
- Menu and category highlighting for a single post
- Menu with category 2 category combined
- Tag Menu items based on their categories
- Code to display category-specific single.php is overriding normal single.php, too
- Loop Through Categories in Custom Field
- Backend – Categories and Menus conflicts
- Hide category links if there is nothing in the categories – Main Navigation submenu item
- Using categories and pages in menus
- Category menu that filters out empty categories
- How can I add a Categories page link to a menu? [closed]
- Function to list posts from current post’s category fails in WP 3.8
- Right way for setting categories
- Make three menus with three category levels
- Show only one category in main query, issues on tag page
- Remove the current item from a menu
- Chained drop-down menu for custom taxonomy using chained.js
- Update wordpress menu with woocommerce products