Use get_cat_ID(‘categoy name’) https://developer.wordpress.org/reference/functions/get_cat_id/
<?php
$category_id = get_cat_ID('Category Name');
if($category_id > 0){
echo 'category exists';
}else{
echo 'category NOT exists';
}
?>
Related Posts:
- Making Woocommerce optimized for more than 500k products
- filter on get_posts efficiently
- add_action hook for completely new post?
- WP_Query leaking absurd amounts of memory
- Register custom query args parameter for WP_Query()
- How to add multiple custom URL variables?
- Getting wrong relationship value in $args in wp_Query?
- Check for featured image in WP_Query
- Why Does get_posts() Return an Empty Set?
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How to ensure “the_content” filter runs only for the main displayed content?
- add_filter and remove_filter added before and after wp_query
- How can i list current author’s categories?
- How to Make a Category Always Selected?
- How to get all images and their thumbnails from wp media library
- anything like add_meta_box for categories?
- Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?
- Missing “category_children” option when dynamically creating categories via a plugin
- How to create a dynamic page based on form data with a plugin?
- Can we create a category list page in WordPress?
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- WP Query group/order by category name
- prevent showing posts of an specific category in admin posts section
- Handling form request from plugin file
- prevent post to have multiple categories in my plugin
- Cannot search post by taxonomy
- How to get orders with used coupon in WooCommerce
- WP_Query with tax_query, order by most ‘matches’
- How to print raw query from WP_Query class just like in CodeIgniter
- WP_Query returns no results
- Show add_meta_box by selecting a specific category
- Finding posts containing matching array elements in a meta field usign WP_Query
- Create a custom display order in the main menu
- manage_posts_custom_column, showing serial number using increment in loop
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- Slow WP_query due to nested wp_query. Need Suggestions
- Is it possible to change a term slug before being saved to the database?
- ORDER BY wp_post custom column name in wp_query
- wp_insert_category() setting the ‘cat_ID’ gives not array error
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- Send push when new post is published in a certain category
- How to fetch only current hour posts?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- How do I get the sub categories of the parent when in a sub category?
- Search: how to extend the existing search to include a custom table
- how to get all the child category name in a specified category name?
- Filter Categories widget to allow custom sorting?
- how to invoke wordpress API from other existing PHP system
- How I can use order by of the custom post title?
- Function/Class to list categories with checkboxes
- How to query children by post name/slug
- 400 Bad Request, in wordpress theme development, wp_ajax
- Prevent WordPress automatically processing certain URL queries
- Check if post belongs to any category
- Store custom meta box data as serialized array
- How to display the categories on page using shortcode?
- How to display the category id along with category name on categories list?
- How remove trashed WooCommerce orders from wc_get_orders() result?
- add_action pre_term_description vs. pre_category_description
- How to show parents of current page category, excluding the category?
- Auto-complete or auto-suggest from stored data in database
- WP Dropdown Categories, display subcategories but not grandchildren categories?
- Get post thumbnail in WP_Query
- Pagination not working with custom wp_query
- Get Posts by IDs (optionally)
- Load stylesheet in edit category page?
- How to relate the Category to user?
- How to exclude categories from get_categories() select list inside a widget admin panel
- Exclude Woocommerce Product Category From Sitemap
- WP_Query order posts by category
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- How to show only the last two categories in a menu?
- Multiple dynamic Tax Query – pass taxonomy argument from array
- Determine if term is Category or Tag
- WP_Query not ordering correctly
- Home page is not loading, where in other pages are displaying on the site
- how to create a shortcode from a variable in plugin
- delete category on plugin deactivation wordpress
- User meta query using Wildcard
- Hide post by ‘post_category’
- WP Query date_query with several date range
- Woocommerce product not appearing in category list page when created programatically [closed]
- Yoast and another plugin
- Add a new tag based on the category name in the publish event
- Post Pagination does not working on WP-Query
- WP Query Relations / Compare
- pull data from wordpress database
- How can I query 3 posts from diferente categories (one of each category)
- Query only title/field/featured media of posts [closed]
- post_results filter confused by pagination in sidebar and main section
- Creating an archive page listing external data
- Can’t get query string in ajax call
- Get custom wp_query search results to appear on search.php
- How can i call from custom fields to the category editor?
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- $_GET vs get_query_var()
- What is the meta_query key name for the woo product average rating? [closed]
- get the queried_object of an url
- Return custom product in ajax call loop
- How to get recent one post from each category on home page?