How can I insert a slug instead of an ID in this code?
-
I’d like to use the slug of the category instead of the ID (
62
). For example, I’d like to insertwatch-isatv
in place of62
. Is this even possible and if so, how can I format it?function excludeCat($query) {
if ( $query->is_home ) {
$query->set(‘cat’, ‘-62’);
}
return $query;
}
add_filter(‘pre_get_posts’, ‘excludeCat’);Also, I tried using (
category_name
,slug-of-post
); but that didn’t work either.
- The topic ‘How can I insert a slug instead of an ID in this code?’ is closed to new replies.