is_single()
is intend to work with post types, not categories.
To check for category you should use is_category('programming')
.
Note that is_category
works on category archives, not on single view.
So, if you want to check in the current is a single view and has the category ‘programming’ you need the has_term
tag:
if( is_single() && has_term('programming', 'category', get_queried_object()) ) {
include_once ('TEMPLATEPATH/get-messages.php');
exit();
}
See is_single, is_category and has_term on Codex.
Also have a look on how conditional tags works in WP.
Related Posts:
- Is there a WordPress plugin that registers a plugin file as a custom page template?
- Get the category from an ID of a product?
- Is it possible to stop selected plugins from loading on certain template pages?
- Way to force media uploader use custom image size
- Restrict access and display for categories
- Plugin for changing a post’s category based on it’s post date?
- Why am I sometimes getting a 404 error when I try to update a page with Elementor?
- How to display a category list in a mediawiki like way?
- Template plugin for blog posts? [closed]
- How to show custom static content at top of each category page?
- How to use get_categories() with Event Organiser plugin
- Server-side subscribe by email?
- Adding a post shortcode to a page template?
- How to correctly detect accessing wp-content/uploads?
- Calling custom plugin class methods from a template
- Create a custom page template inside my wordpress plugin
- Custom Post Type Plugin not loading category template and loading 404 instead
- Display content from custom post type if match to main post category
- How can i list random post from multiple category?
- My Category is too big on the Menu what can i do?
- Getting a List of Categories for Use in a Plugin?
- WordPress category add image field
- Register Page Template from Plugin
- Easy Digital Download Sub category
- Solutions to repost categories into multisite blogs?
- Assign post format to categories
- Using WP Category Lists Plugin to Dynamically Display Category (PHP)
- Events Plugin that works with existing categories?
- Trouble with editing template for “List category posts” plugin
- Any built-in function to associate a post to category through a plugin?
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Search for categories
- Redirecting thousands of posts that currently have no category in their permalink when changing permalink structure to include category
- Automatically Assign Author to Category [closed]
- polylang + category/tag custom language link
- WordPress “Categories to tags converter” not working. Pointing to import.php instead
- How do I apply style to each category of a list?
- How to use get_template part in the plugin?
- Show author on every sub-page
- Create custom template in plugin and display it into post template section?
- How do I rename a category in the menu bar only?
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- Default taxonomy template in plugin, override in theme
- Is changing post from category in a large blog a good practice?
- How to set category correctly for a custom post created by a remote API call?
- Trying to add a page template for my custom post type from a plugin, but it will not display in the template dropdown unless file is in theme
- Mutliple users editing single document in wordspress
- How to add category and subcategory in WordPress custom code?
- Custom form not showing in correct place on page
- Call another page in forms
- Ajax Call in page theme not working?
- WooCommerce Hiding A Certain Category From Being Displayed On Single Product
- How to dynamically change spots of text in custom page?
- How to modify the Loop from a plugin (instead of a theme)
- Category “same post” retreive and display
- Add a new category for posts
- How to hide featured images of all posts falling under the same category in wordpress?
- how to show all posts of each category in pages
- Custom Post Type same name as Category
- Give custom page template a custom post ID
- Display posts by alphabetical order
- How to display category list with category featured image
- Getting the same post on my related post
- Precheck fields when I add a new post
- automatically set random featured image by category in wordpress on post
- how can I edit the HTML of yith ajax product filter
- WordPress Product Detail and catalog
- WordPress Categories as a Grid
- How to allow editors to only edit certain categories?
- Plugin json page
- Category as Subdomain for One WP Install
- Woocommerce categories displayed on every category and shopping page
- woocommerce product search based only title
- Passing variable from template file to the plugin file
- How to differently style pages that display posts of different category in WordPress?
- Related post based on 2 categories
- How to insert category name above post title in a featured pages plugin?
- Custom Page Templates for a complex application – code must sit in a plugin and not the Theme
- Displaying saved category checked in a plugin?
- WordPress Categories from Plugin
- Showpost and last
- Is it possible to setup Category wise Subsciption?
- Filter EVERY category link with my plugin
- Category archive in menu
- CSV file header
- Find And Add Category to Posts
- Retrieve post thumbnails
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- Editing “Kahi’s Highlight Used Categories” plugin code – highlighting parent and child category in post page
- wp_insert_post_data filter to set category
- 404 not found problem with URL rewrite custom category
- Automatically set posts to NoIndex depending on category?
- Sort Reviews/Ratings by date on Woocommerce
- Make a Custom template for a specific category in wordpress
- query_vars in plugin when using custom permalinks
- How to pre-set WordPress settings for specific posts?
- Create WordPress category dynamically
- Can i have limit posts on a specific category and automatically remove older ones?
- Categories not showing when all of the posts are private
- How to add portfolio category post count in main navigation menu?