Where to put Snippets in your WordPress Functions.php File

Where to put Snippets in your WordPress Functions.php File featured image
(Last Updated On: November 29, 2016)

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 Reply

Your email address will not be published. Required fields are marked *

Silicon Dales