dev3 ·
I need to add a shortcode, a post type and a few CSS tweaks to a client site. Is a child theme enough, or should I write a plugin?
#wordpress#child-theme#best-practices
0
DEV3 Developer Forum
Every post is reviewed first. Usually reviewed within 24 hours.
I need to add a shortcode, a post type and a few CSS tweaks to a client site. Is a child theme enough, or should I write a plugin?
#wordpress#child-theme#best-practices
Rule of thumb: presentation goes in the theme, functionality goes in a plugin.
Child theme is for
header.php, single.php, partials copied from the parent).Plugin is for
functions.php, switching themes makes the content disappear from the admin.For your list: shortcode and post type go in a small plugin, the CSS tweaks in the child theme (or Additional CSS in the Customizer).
Minimal plugin:
<?php
/**
* Plugin Name: Client Site Functions
* Description: Site-specific functionality.
* Version: 1.0.0
*/
defined( 'ABSPATH' ) || exit;
add_shortcode( 'year', fn() => esc_html( gmdate( 'Y' ) ) );
Save it as wp-content/plugins/client-site-functions/client-site-functions.php and activate it.
Must-use plugins (wp-content/mu-plugins/) load automatically, cannot be deactivated from the admin, and suit essential site rules.
Pitfalls
client_), and guard with defined( 'ABSPATH' ).theme.json overrides; see the DEV3 child theme starter.