How To: Add custom PHP code to WordPress

0 22

Get real time updates directly on you device, subscribe now.

Your code will only do what you need and what you want, and keep your WordPress install light. For me, there are two main ways of adding custom PHP code to WordPress. I’ll start with my most recommended one.

Code Snippets

- Advertisement -

I truly love this plugin, it’s perfection. If it disappears one day, I’ll code it right away, and just the same. You can install it from the WordPress Repository, it’s here. Then, here is what it looks like in WordPress:

Add custom PHP code to WordPress

You can see what I did with it, like above. You can use this to customize almost everything about your WordPress or modify the behavior of certain plugins, like mine. You can also choose whether you would like those snippets to be run all the time, or maybe only on the front end or only on the back-end.

I recommend you to use this. It will follow your website when you migrate it, you can see at all times your code snippets and even name them, it’s really tidy.

Or, into the depth of the functions.php!

In your theme, there is a functions.php file. It’s probably already full of code, but it’s pretty common to add some additional code in there, at the end of it.

I only recommend you add code directly in your functions.php if the code is extremely dependent on the theme itself and/or if it’s your own theme, made specifically for your website. Also, if someone, like a developer or the theme maker, updates it, then your changes are gone.

Go for Code Snippets. Except if you know exactly what you are doing. But in that case, why did you check that article? 😋

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More