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
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- 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?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- 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
- Which are the hooks run before/after when a category’s deletion?
- Create a custom display order in the main menu
- manage_posts_custom_column, showing serial number using increment in loop
- Error : “Cannot use object of type WP_Post as array in”
- Proper way to run wp_query from inside a plugin
- using new WP_Query in save_post function alters $post
- 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
- How to create database table, add data, update and delete using wpdb via plugins?
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- Send push when new post is published in a certain category
- WP_Query filters
- How to fetch only current hour posts?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- WordPress pre_get_posts with combined results of two queries (OR)
- 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
- Redirect to another page using contact form 7? [closed]
- 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
- How can I show posts for a single 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
- Post is uncatagorized in publish_post action
- User meta query using Wildcard
- Group By in a Metaquery
- 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]
- Custom MySQL query to pull out Advanced Custom Fields?
- 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?
- loop and in admin header problem
- How do I query posts and have their related taxonomies returned in the results?
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- $_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?