Where to put Snippets in your WordPress Functions.php File

Every so often, on the WordPress.org forum, or some blog comments thread, or on Twitter, or some other place, we see helpful open source practitioners posting snippets to be added to “the end” your theme’s (child theme, child theme, please use a child theme) functions.php file.

Then we hear of someone who has done exactly that and met with unexpected results, like a whitescreen or some other problem.

How to fix that?

Well, assuming the code snippet was correct (even gurus make typos, especially in blog posts or StackExchange answers!!!), then you might have placed the code in the wrong place.

If your functions.php has a closing PHP tag, which will look like this:


You should place your code before that line, leaving the


as the last thing in functions.php – got it? Okay, now, if it doesn’t work, you got something wrong with your snippet!

Tell us if this worked!

Leave a comment below if this worked / didn’t work for you!

Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.