I am trying to exclude categories from the WordPress loop. I have an admin area that has a text box that you can enter the category slugs that you want to exclude. I am having the hardest time trying to figure this out. I am using the SMOF framework. A simple input box that returns a string. So when I echo out my test, I can get
homepage recent-news
I tried a foreach loop to get the category id but it isn’t working. I keep running into php errors. I have been trying to use the get_category_id_by_slug() function and I can’t even get it tested. Right now I tried the simplest test like so
$slug = 'homepage';
$category_id = get_category_id_by_slug( $slug );
echo $category_id;
This returns an error saying this
Object of class stdClass could not be converted to string
It shouldn’t need to be converted to a string because it already is one.