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?
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?
You must be logged in to post a comment.
You can use List Category Posts (Disclaimer: I’m the author of List Category Posts) or you can code this yourself:
This way you can get the id and exclude it from the loop with the minus sign. Example:
No.
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.