Skip to content

Adding PHP

If you need to add PHP logic (custom hooks, filters, shortcodes, etc.), the safest method is to use the Code Snippets plugin. This keeps your changes up-to-date, safe and easy to manage

Recommended plugin

Why use Code Snippets

  • No theme files edited
  • Easy enable/disable per snippet
  • Update‑safe
  • Great for quick customizations

How to add a snippet

  1. Install and activate Code Snippets
  2. Go to Snippets → Add New
  3. Paste your PHP code
  4. Choose where it should run (front end, admin, everywhere)
  5. Save and activate

Example: Add a custom body class

<?php
add_filter('body_class', function ($classes) {
    $classes[] = 'custom-site-class';
    return $classes;
});

Advanced option

For larger PHP changes, use a child theme or a small custom plugin instead of snippets.

BBI Brandboost
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.