Want to add custom PHP code to your WordPress site? It’s simpler than you think with the WP Code plugin. Let’s dive straight into the steps to get you started.

 

Step 1: Installing WP Code

Install and activate the WP Code plugin.

WP Code is a phenomenal tool that supports custom PHP, JavaScript, CSS, HTML, Text, and other custom code snippets.

It can automatically run your code site-wide or in specific locations like before post content, in the header, or even the footer.

To add WP Code to your site, navigate to the Plugins section on your WordPress dashboard and search for “WP Code”.

 

Step 2: Adding Your Custom Code

Now that you’ve got WP Code up and running, it’s time to add your custom PHP code.

From your WordPress dashboard, hover over WP Code, then click ‘Add New’.

 

You’ll be taken to a new page where you can start writing your custom code.

Once you’re on this page, look for an option titled “Add Your Custom Code(New Snippet)”.

Select it, and then choose the code type to PHP in the dropdown that appears.

With that done, you can add your PHP code to the code editor.

 

Step 3: Choosing Where Your Code Goes

After you’ve written your code, you’ll need to decide where it should be inserted. Scroll down to the ‘Insertion’ section of the page.

You’ll see two insertion methods: “Auto Insert” and “Shortcode”. With ‘Auto Insert’, you can set the code to run everywhere or at specific locations like site-wide headers or footers.

‘Shortcode’, however, generates a shortcode that allows you to insert your PHP code wherever you’d like.

For this guide, we’ll choose the ‘Shortcode’ option. After selecting ‘Shortcode’, don’t forget to activate and update your code.

Once updated, you’ll get a generated shortcode. Make sure to copy it for the next step.

Step 4: Executing Your PHP Code

On the front end of your site, paste the shortcode you copied in the previous step.

Once pasted, update the page. Your PHP code will be executed on the page.

 

Adding PHP code to your WordPress site doesn’t have to be a daunting task. With WP Code, you can easily customize your site, take control of your content