Home > Docs > Adding Custom Code Snippets using a Third-Party Plugin

Adding Custom Code Snippets using a Third-Party Plugin

Last updated on July 17, 2025

Adding custom code snippets is one of the most powerful ways to enhance or extend a plugin’s functionality. One of the easiest and safest ways to add custom code snippets is by using third-party plugins. This article discusses how to add a custom code snippet using the Code Snippets plugin.

Code Snippets

The Code Snippets plugin is a powerful tool that helps add custom code snippets to a WordPress website without modifying the theme’s files directly, thereby reducing the risk of compatibility issues and making updates smoother. To add a custom code using the Code Snippets plugin, follow these basic steps:

  1. Install and activate the Code Snippets plugin.
    • On installation, a Snippets icon will appear on the WordPress dashboard.
  1. From the WordPress dashboard, navigate to Snippets > Add New
  2. In the Add New Snippet window, type in a suitable Title, Code, Description, and Tags in the space provided.
    • Make sure that the Functions (PHP) tab is active.
Add New Snippet
Add New Snippet
  1. Select the location to run the code snippet from the four options available.
    • Run snippet everywhere: Executes the code throughout the site.
    • Only run in administration area: Executes the code within the WordPress admin dashboard.
    • Only run on site front-end: Executes the code only on the public-facing part of the website.
    • Only run once: Executes the code only once.
Select the desired area to run the snippet
Select the desired area to run the snippet
  1. Click on Save Changes and Activate to save and activate the code snippet.
Save Changes and Activate
Save Changes and Activate

Example

So, let’s take an example of adding a custom code to alter the font size in a WooCommerce Address label.

  1. As an initial step, enter the title, code, description, and tags in the space provided, as shown below.
    • Make sure the Functions (PHP) tab is active.
Custom code snippet for altering font size
Custom code snippet for altering font size
  1. Then, select the desired area to run the snippet.
Select the desired area to run the snippet
Select the desired area to run the snippet
  1. As a final step, click on Save Changes and Activate to save and activate the snippet.

Managing code snippets

  • To view and manage the snippets, navigate to Snippets > All Snippets.
  • One can view, edit, clone, export, and delete snippets under the All Snippets tab.
All snippets page
All Snippets page