Add Functions and CSS Without Modifying your Theme

In this quick article, I want to mention how you can add functions and CSS without modifying your theme. This keeps it safe from theme updates and in general is good practice if you aren’t using a child theme, or if you’re making quick changes you’ll properly add in later.

We’re going to use two plugins for this which I’ve had a lot of success with – there are undoubtedly others, but these are my top recommendations.

Add PHP without modifying your Theme

To add PHP (which most guides will tell you to add to functions.php), instead use My Custom Functions. This adds a nice area under your Appearance tab in your WordPress Administration where you can add PHP code. A neat bonus to this plugin is that if code is going to crash your site, the plugin does it’s best to stop that. Keep in mind nothing beats a staging site or development server, so always have backups!

My Custom Functions on the Repository

Add CSS without modifying your Theme

To add CSS (which most guides will tell you to add to your style.css file), you can use the built-in CSS area of your theme if it has one. These areas are designed to not be overridden during updates. However, I like to keep my code separate as an extra insurance measure – for that reason, I like Simple Custom CSS. Like My Custom Functions above, it adds a nice area under “Appearance” in your WordPress Administration for your custom CSS, and in general is just a breeze.

Simple Custom CSS on the Repository

One Parting Note

I want to also clarify that these aren’t necessarily replacements for adding code properly to a child theme. If you do have a child theme or customization plugin and are comfortable coding, then it’s much better to add the code there eventually – however, this is an appropriate way to add code if you don’t have a child theme and don’t want to make one or if you’re trying to customize a pre-purchased child theme.

That’s all there is to it! By adding features there, you keep them safe from theme updates. If you’re using a child theme like I mentioned earlier, then these are still good places for temporary changes or quick fixes before you mix them into your theme.

Have any questions or comments about this article, or ways you think it can be improved?
Join the conversation in the comments below, or sign up for my newsletter to recieve periodic updates!

Tags: , ,

No comments yet.

Leave a Reply

%d bloggers like this: