Applying code in Wordpress functions.php to only one category

admin

Administrator
Staff member
Is there a way to limit the following code that I've added to my functions.php file so that it only applies to a single wordpress category?

Code:
<?php remove_filter('the_content', 'wpautop'); ?>

I tried this, but it didn't seem to work:

Code:
<?php if (in_category('work')) { remove_filter('the_content', 'wpautop'); } ?>

I should also add that I solved this problem by placing the code directly in the specific category template, but I'd prefer to keep the filter in my functions file.

Thanks!