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

I would like to exclude categories from the loop using the "name" instead of the "id", since the ID can change when using new databases. The name however will always be the same.

Is this possible?

share|improve this question
up vote 3 down vote accepted

You can use List Category Posts (Disclaimer: I'm the author of List Category Posts) or you can code this yourself:

$category_id = get_cat_ID($category_name);

This way you can get the id and exclude it from the loop with the minus sign. Example:

share|improve this answer


WordPress very forcefully converts input of that argument to integers and is it part of sub-query from tables that don't actually contain category names.

You might be able to construct your own analogue using posts_where filter to modify SQL... But I think if you don't need a lot of categories to exclude it would be way more practical to simply convert names to IDs before querying.

share|improve this answer

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.