For styling archive index pages for a given category, target body.category-slug
(where slug
is the category slug) in CSS.
For styling single blog posts that have a given category, assuming your post container is a div, target div.category-slug
(where slug
is the category slug) in CSS.
For PHP operations, you can also use is_category( 'slug' )
, which returns true if you are on the archive index page for a given category, and you can use in_category( 'slug' )
which returns true if the current post is in a given category.
Related Posts:
- Can I hide a specific post from latest posts page?
- How to show post(excerpt) from specific category on wp page?
- Can I divide the pages into categories?
- Should I use posts or pages in this scenario?
- post categories
- Post categories to pages
- How to create a “latest news” page showing a list of posts from blog category
- Having pages after specifying post_type post
- Are post, page and category IDs unique to each other?
- posts going to 2 pages/categories only show up in 1
- How can I add a page that shows posts from a single category?
- Automatic duplicate/copy of post to a related page in WordPress
- Yoast breadcrumb URL shows category instead of the page
- How to distinguish pages created by woocommerce?
- How to add a block to a category page?
- Page with Category Returning 1
- Post Category link is same with Page link
- How do I make it so that new posts within a certain category go into a certain page?
- Precedence of page permalinks over woocommerce product category links?
- Show only top 3 posts from 3 categories in order on home page
- Displaying only posts from a certain category on my custom page template
- I need to create a page or post hierarchy
- how to style an individual page in a category [duplicate]
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- wordpress category Description not allowed tag
- Get the Current Page Number
- Stop WP from creating “Sample Page” and “Hello World!” post
- Including categories in search results
- Count how many posts in category
- Custom Single Post By Category
- Convert custom fields to post categories
- Query posts from current year
- Display posts by tag on page
- Can I change a post to a page by changing it’s type?
- Show One Category on Post
- Add a custom option to a page in backend
- Creating new page with pre-defined parent page
- Populating a page with content from post custom fields
- Do I use custom post type or something else?
- What Defines What Category A Post Picks (if in multiple)
- Limit function to specific post category
- Add Category name to Post Title (h1)
- disable column on post and user list
- Can a page_id and a post_id be same?
- Getting a 404 error when clicking edit page
- How to display related posts by subcategory and not parent category
- Category Template: Need to display different content on first page of archives
- Display post category in foreach loop with category link
- How to limit posts by category
- How to list recent posts in a wp nav menu?
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How to display two blog categories as separate sections on one page?
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- How do I do a page break?
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- why does wordpress ignore the post args?
- static landing page leading to author specific pages w/ “live” content
- get posts from Custom Post Type & Category
- WordPress 302 Redirect to Random Product/Post/Page
- Sort by last word in title
- Give posts a particular template based on the assigned category
- Post-Archive like a page in a specific subdirectory
- How to display only one category in a custom post type?
- Get only X number of categories
- inserting a category into post
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Direct some posts to only appear on a specific page
- Creating a redirect option for current page url
- Display a specific category in a focused area of my site
- I want to add another search box on posts page in dashboard
- WordPress: Develop multiple posts with different data
- Does having category name in permalinks affect SEO when having a post in multiple categories?
- How to display related post from same category in single.php
- Save All Post Permalink From A Specific Category into a .txt file
- show image gallery in archives or category page
- Using WP page password protection as defacto login
- get current index of post content in category page
- Dynamically load posts based on category
- Get Categories & Posts With Type Article
- Set multi posts random categories and tags
- Add new post only in assigned category
- Changing the Category for all posts of an Author
- Admin Post List Only Show One Category
- Page not loading content – Body archive – page
- Same sidebar in all posts as in the category
- How do I list categories and the common categories for posts beneath those categories?
- Latest Posts not in the right order
- Using Post ID and Page ID in same function
- How to Include a common category in a custom Category Search
- Redirecting posts in WordPress to a specific page
- Viewing category won’t show up Custom post type posts
- Wrap div-tag around posts in page
- When and how will php code in a user made WordPress page be executed?
- Post data returning null [closed]
- Listing category and its posts one by one
- Print out one of 2 post category [closed]
- How to get if category has posts?