QUICK TIP - 3 Easy Ways to Add a Function in WordPress – Beginning level

0 243
3 Easy Ways to Add a Function in WordPress – Adding functions on your WP website is general and bring for you more benefits such as your website is more flexible to customise in order to support your ideas, and designs. Thus, this function is so very crucial and you need to handle the code well without any error after injecting it in your website.

Problem finding

In some special situations or demands, you may need to add a function such as read more function, change text, or animation to your WordPress website, either to hook something into the theme, or use a filter to change something in the theme. There are some popular themes like mythemeshop, GeneratePress. Therefore, this tutorial will help you to solve the question that how can I add a function (PHP) in my website?


Normally, when working with PHP, you want to make sure you have access to your server via FTP or File Manager through your hosting control panel. This is due to how unforgiving PHP is, if there’s an error in the code, your site can turn into a blank white page and other bad situations. To fix this, simply go into your server and delete the code you added.

Code Snippets

In WordPress, the Code Snippets plugin is a very cool way to add PHP snippets to your website. You can activate and deactivate certain snippets, and even adds notes about what they do. It even has better error handling to avoid the PHP error scenario I mentioned above. Furthermore, I also tested many plugins and this plugin has performed great and stable and compatible with version 5.2 at current time. To install it, simply go to Plugins > Add New and search for Code Snippets.

Create a Plugin

If you don’t want to use the Code Snippets plugin mentioned above, you can create your own plugin. Usually, creating a plugin is kind of difficult, but we can actually use a plugin to make creating a plugin easier. First, install “Pluginception” by going to Plugins > Add New and searching for “Pluginception”. Now that it’s activated, go to Plugins > Create New Plugin. Name it something super specific to you so it doesn’t conflict with any other plugins, and create it. Now you can add your functions to the plugin file.

Use a Child Theme

If you’re already using a child theme, you can use the functions.php file to add your PHP. This method requires that you need to access your website folder via FTP.


Because the complexity of PHP code injection and unexpected errors through some technical methods when you are beginner. So, I suggest that method 1 – using Code Snippet is the best solution for this task. It so easy and very simple for WP beginners.

You may also like

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