1. Home
  2. Docs
  3. Customizing
  4. Adding Custom Code The Right Way

Adding Custom Code The Right Way

Adding custom code to a website is a common practice in the WordPress environment. We are currently running a bit of custom code on our site and this is how we have done it.

Follow these easy steps to create a custom WordPress plugin for your code:

  1. Create a folder on your desktop called ‘my-custom-plugin’.
  2. Enter that folder and create a new file called ‘my-custom-plugin.php’
  3. Edit the ‘my-custom-plugin.php’ and add the following code to it and save your changes:
    1. <?php
      Plugin Name: My Custom Plugin
      Plugin URI: https://yoohoothemes.com
      Description: All Custom Code Goes Here.
      Version: 1.0.0
      Author: YooHoo Themes
      Author URI: https://yoohoothemes.com
      Text Domain: my-custom-plugin
  4. Zip your ‘my-custom-plugin’ folder and upload it to WordPress under the ‘Plugins’ > ‘Add New’ > ‘Upload’ page in the WordPress dashboard.
  5. All your custom PHP code may be entered after the code above going forward.

This allows you to group your code neatly according to plugin and all your code can be in one place, making it easier to support and maintain.

Tip: Reference from the WordPress Codex – https://codex.wordpress.org/File_Header

Tags ,