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 update‑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
- Install and activate Code Snippets
- Go to Snippets → Add New
- Paste your PHP code
- Choose where it should run (front end, admin, everywhere)
- 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.