In many cases, you will need to add custom PHP code in the theme. In this article, let us explain some ways how you can do so:
1. With Third-Party Plugin
There are free plugins available on WordPress Repository that you can use to add custom PHP code. Below are two of them:
2. In Child Theme
You can add a filter or custom PHP code through the WordPress Dashboard, follow the steps on how you can do the same –
Step 1: Install and Activate the Woostify Child Theme from the WordPress Dashboard > Appearance > Themes > Woostify Child Theme.
Step 2: Open the Theme Editor under the Appearance. Not seeing Theme Editor, troubleshoot the same.
Step 3: Navigate to the child theme’s functions.php, from the right-hand section and select functions.php.
Step 4: Add your code at the bottom of the file and click on Update File at the bottom.
Note: If you have the Parent theme active and visit the Theme Editor, you will see the following message, which informs you about how directly editing your theme could crash your website. Click on “I understand”.
Or if you have access to cPanel of your website, you can use FTP software like FileZilla. Below are the steps that explain how to do so –
Step 1: Install and activate the Woostify Child Theme from the WordPress Dashboard.
Step 2: Open your WordPress site via FTP. We would recommend you to use FileZilla.
Step 3: Navigate to wp-content > themes > woostify-child
Step 4: Right-click functions.php and select
Step 5: Add your code at the bottom of the file and save it.