Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category

The problem was that the remove_filter function wasn’t working. Apparently this is not uncommon from what I’ve read. I tried testing it with different priorities (1, 9, 20, 999), but there was no difference.

So my filter in the child theme and the filter I was trying to remove from the parent theme both had the same priority. WP loads the child theme’s functions.php right before the parent’s so I’m guessing that’s why my filter was not taking effect because it was happening first and then being filtered again by the parent’s.

Anyways, my solution was simply to change the priority of my add_filter function to 11, like so:

add_filter('single_template', 'single_template_override', 11);

Leave a Comment