Instead of writing custom SQL, you should be able to just use the native get_category_by_slug()
which will return a full category object to include the category ID.
Related Posts:
- How to create 450 categories in wp
- Custom Query to search through categories
- How Do I Merge Categories With phpMyAdmin
- Disallow categories from this MySQL query
- Accessing WordPress MySQL Database via Data Connection in Visual Studio 2010 using C#
- Change the category of all posts in it
- How to run select query of post with category and tags for API?
- How to get related tags based on a category?
- SQL to migrate post types to taxonomy
- Drop posts from categories in MySql
- WordPress Post # of # filtered by category slug
- Can Categories be used to hack a Multisite-like setup w/ a single MySql db?
- How to list all categories and their IDs using SQL query?
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- How to add categories using mysql
- How do I merge WooCommerce categories with the same name?
- Bulk Change WordPress category Slug
- how to get postmeta info based on multiple categories?
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- How to make that all posts with a category belong also to another
- Control term order on a per-post basis
- Display all posts from all categories with pagination
- Changing Top Level Items into Radio Buttons in the Categories Meta Box?
- How to create a widgetized sidebar for every category dynamically?
- Display the deepest child category from Category X (in loop)
- When using get_categories or similar, is it possible to filter results that contain certain Tags as well?
- WooCommerce – Display product child categories from specific parent
- Select category in custom query
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Show list of categories even if they have no posts
- How to control template resolution if both Author and Category filter in place?
- Resolved – category-slug.php not working after wordpress migration
- How to retain the values from dropdown category lists after wrong form submission?
- Format Brand value in Category view [closed]
- Get multidimensional array that reflects category hierarchy
- Single_cat_title() print the title before text
- Sort posts by post_type in category.php template
- Add Post Screen Keep Category structure
- Possible to make a subdirectory that loops through a single category?
- editing fonts of category links from the_category() funtion
- Force a user’s posts category
- Automatically set default password to all posts in a specific category
- Style wp_list_categories
- Checking for two categories in query_posts
- get_the_categories filter returns an empty array
- Warn me about ‘uncategorized’ posts
- Categories showing page not found
- Why category.php throw 404 in wordpress while calling paginate_links()?
- Show category to visitors in different name or different language without changing basic category
- How to get latest posts from each category in regular order
- Pagination for ajax category filter
- Get posts from specific taxonomy term
- limit a list of tags to one category [closed]
- How many categories can WordPress handle before performance suffers?
- WordPress Drop down category as array for using in page builder
- Get sort order of product categories
- how to wordpress When I click on the category link, subcategories appear
- Show posts in “image” format when viewed in category page, but with comments in blog
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- How to change the order of the subcategory and category in a post?
- Properly setting up a feed
- Display posts of certain categories to specific user roles
- Display Related Posts by “Category” “by Author”
- Change post title if post has specific category
- How to schedule categories?
- Template for product-category page [closed]
- How set all posts in wordpress in one category
- custom query for both category and pages using global $wpdb;
- url for posts for a date within a category
- Autolinking keywords in text with tags
- WP E-Commerce creating categories programmaticaly [closed]
- query_post problem
- Get a list of all links on a page?
- Load the last post of a category
- create function to call category name and slug
- Disable Category Taxonomy
- How to make product image inherit from category image
- Is this process OK to replace URL structure?
- Is it possible to set up blog categories without changing permalink structure
- How to display categories image in loop homepage WordPress
- how to give different template to each subcategory from same parent category?
- No hierarchy in wp_list_categories with child of and depth
- How to check a category checkbox using JavaScript
- Need help to structure our a complex hierarchy
- global categories – Share specific categories in wordpress multisite
- WordPress update 4.7 – the 70.000+ news posts became “Uncategorized”
- How to auto update post title and slug with category name when post status is updated
- Choosing different templates for categories
- Problem with wp_list_categories
- hierarchical taxonomy in permalinks? using same slug
- Display one post on category.php: Wrong featured image
- WordPress Numeric Pagination with Query String [duplicate]
- Changing Permalinks for Category Pages Only
- Taxonomy for custom post type not found
- How can I get this code to only output one link?
- Sorting Woocommerce products by category and attributes
- How to get Woocomerce categories count
- show posts from some category and sort by advance custom field
- Function to reference post meta in place of category Woocommerce
- Category Redirection Problem