How to install PHP code in your WordPress website

The most common way to add PHP code to WordPress is via Functions.php file.

To edit Functions.php file you need FTP access.

If you make a mistake while adding PHP code to Functions.php file, your website will stop working.

If it’s stop working, you’ll see a white screen when you access the site via browser.

Instead of making changes directly to Functions.php file, you can use a plugin called Code Snippets.

How to Add PHP Code to WordPress Using a Plugin?

  1. Download the Code Snippets plugin here.
  2. Install and activate the Code Snippet plugin.
  3. Click “Add New” to add a new snippet.
    add new code snippet
  4. Once “Add New” page is loaded, you can enter snippet title, actual snippet, description and tags as shown below. In addition, you can also choose where to run these snippets.
    add new snippets
  5. Snippets can be run in following places:-
    • Front-end
    • Administration area (back-end)
    • Both front-end and back-end
  6. After entering the snippet, click “Save Changes and Activate” button to save and activate the snippet at the same.
  7. Now the newly entered snippet should be working.

Plugins like Code Snippets provides an easy, clean and simple way to run PHP code snippets on your site.


Leave a Comment