If you want to check whether a certain post has a certain category, you need in_category
, so your test would need to be:
if (in_category($category_name))
Related Posts:
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Combine two taxonomies in a hierarchical tree
- Get current category details the user is currently on in category.php
- Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?
- Get Default Post Category From Settings
- Get the number of posts in a named category, outside the loop
- Test if post has a category
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Create subdomains for tags and categories
- Categories – create a new separate set right after the default?
- How to get this only in small letters (lowercase)? [closed]
- Highlight current category in wp_list_categories
- How to totally get rid of Category in my blog?
- Is there a function to cause empty categories not to show in menus?
- Category Specific Archive
- How to select product category while adding new product in woocommerce? [closed]
- WordPress previous_post_link exclude posts with multiple categories
- How do I count how many top level categories there are?
- How to get the number of child categories a specific parent category has?
- Removing category base form links messes up the parent-child behavior
- display most popular tags of category?
- Exclude category from loop not working
- How to list only child categories?
- Want to hide some categories from the categories meta box in the post editor for the two specific user roles
- Getting categories id for all products in cart
- Cannot add / edit categories to a post anymore
- List archived posts by subcategory
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- Show Different Custom Menu on Different Category Pages
- Show archives by year from just one category
- How to get the id from the custom category?
- Combining post categories and link categories?
- Category being displayed without base parmalink
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- Unwanted Duplicate Product Categories in WooCommerce
- WP didn’t redirect to canonical category URL
- Customize WordPress widget – Product Category
- Display categories with child category separated by letter
- WP admin broken. Not saving catgories or adding categories to menu
- How to make the link to the category for a post go to corresponding page number in archive?
- Set colors depending on category
- get_terms function not returning anything
- Shortcode interpreted as text
- Getting All Post From Specific category in wpdb
- Single.php Category Post Count
- Jigoshop – only displaying 10 products
- Is there a way to only show Custom Meta Data on single posts from certain catagories
- Grouping post-types in loop
- Show the amount of posts in a tag in a specific category has
- display a widget on specific category and its sub categories
- So my theme doesn’t have a category.php file
- Custom page category taxonomy 404
- Template hierarchy: how to let category.php conditionally-load archive.php?
- How to let the user create a selection of categories via the backend
- Display subcategories selectbox on each category page
- Media (images, videos, etc.) not showing on Category page
- Problem with Custom Post Type Categories
- Display post thumbnail for specific category outside the loop
- PHP dynamical conditional post display
- wp_dropdown_categories initial value
- Category Template – Show Last Entry as Featured
- can I ‘combine’ categories as a menu item?
- Displaying categories in different template problem
- List taxonomy terms assigned to a post in hierarchical view
- How can I display image child category in parent
- Limit categories to hierarchal depth of 2
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Show the parent taxonomy by creating shortcode in woocommerce?
- ADD DYNAMIC attribute for category to accordion
- Get_term_meta() does not work with pre_get_posts()
- Unable to add multiple categories to a post in WordPress
- How to display custom fields as table in Woocommerce
- make color of headline depend on category?
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Menu with category 2 category combined
- Displaying Category in sidebar post widget but not in the loop on home
- Categories and Tags Conflict after Woocommerce Installation
- how to display categories for a specific post?
- Media Categories as Classes on WordPress Gallery Shortcode
- the_content() not showing full posts in category template
- Show parent category if there is no subcategory
- Add category links?
- show posts found in multiple categories via category_name query string?
- Category Template for Custom Post Type
- get categories the post was in and just been removed from
- Loop through posts of CatA and store value of CatB in separate array
- Add html word before category
- Display last postings of 5 categories on homepage
- How to enable admins/editors to set a featured image for specific category?
- Category that can hold only specific number of post
- How to add the sidebar in all category page
- Having Trouble With get_category_by_slug In a Custom Function
- WordPress category gives 404 after moving to a different domain
- how to ask if in two categorys inside if
- Print child category slug nicename
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- Restricted category in Woocommerce [closed]