WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

basically, I have a cookie with the category slug stored, using this data I want to query the database and return the ID of the category.

I am new to mysql and this seems like an advanced query that may need to use joins, any help or guidance would be much appreciated.

Thank you!

Reference: http://codex.wordpress.org/File:WP3.0-ERD.png

share|improve this question

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.

share|improve this answer
It is in a file completely separate from wordpress. – Mr D May 19 '12 at 2:50
What is in a file completely separate from wordpress? – mor7ifer May 19 '12 at 10:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.