category__not_in — anyway to use category name instead of id?

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?

Related posts

Leave a Reply

2 comments

  1. 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:

    get_posts(cat=-1);