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

1 Answer 1


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.

  • It is in a file completely separate from wordpress.
    – 1321941
    May 19, 2012 at 2:50
  • What is in a file completely separate from wordpress?
    – mor7ifer
    May 19, 2012 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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