Hi, I’m trying to edit functions.php to add code to exclude a category from displaying on the blog, but I keep getting an error message!
Here’s the code:
function x_exclude_cat_from_blog($query) {
if ($query->is_home() && $query->is_main_query()) {
$query->set('cat', '-5');
}
}
add_action('pre_get_posts', 'x_exclude_cat_from_blog');
Here’s the error message:
Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.
It seems to have started coming up with that error message after recent updates, as I’s already added in some code so my global block would appear at the footer of every page and even when I don’t add any new code and just go to update the functions.php file, it comes up with the error message!
I have no idea what’s causing the error message, but I’m hoping you might know!
I’ll put the URL in a secure note as it’s on a temp link.
Thanks!