Get started

Add custom code with WPCode

Add PHP, HTML, JavaScript, or CSS snippets with the WPCode plugin instead of editing functions.php.

You can put small PHP snippets in your theme’s functions.php. That works, but a theme update can overwrite the file, and a PHP error can break the site.

A safer option for many sites is WPCode (Insert Headers and Footers) from WordPress.org. It stores snippets in the database and can disable a snippet if it throws an error.

Install WPCode

  1. Go to Plugins → Add New.
  2. Search for WPCode (plugin title often includes “Insert Headers and Footers”).
  3. Install and activate it.
  4. Open Code Snippets in the admin menu.

Add a snippet

  1. Go to Code Snippets → Add Snippet (or Add Your Custom Code).

Add a new custom snippet in WPCode

Create Custom Snippet screen in WPCode

  1. Give the snippet a clear title.
  2. Paste the code.
  3. Set the type (PHP, HTML, JavaScript, or CSS).
  4. Enable the snippet and save.

Enabled custom PHP snippet in WPCode

Only add code you trust. WPCode reduces downtime risk; it does not make unsafe code safe.

Still stuck? Get help or contact us.

Larger screenshot

Enlarged image