Child theme
Child theme
Set up a child theme for a PremiumPress theme, with the two lines it needs that a standard child theme does not have.
What it is for
A child theme holds your own code next to the theme, so updates replace the theme's files without touching yours. Use it for your CSS, your PHP functions and your hooks.
It does not let you replace the theme's page templates by copying them over. PremiumPress loads its pages from its own folders. See Page layouts for what to do instead.
The two files
Create a folder in wp-content/themes/, for example my-site-child, with these two files.
style.css
/*
Theme Name: My Site (child)
Template: DT12
Version: 1.0.0
*/
/* Your CSS goes below. */
Set Template: to the folder name of your PremiumPress theme, exactly as it appears in wp-content/themes/ (for example DT12 for the Directory Theme, JB12 for the Job Board Theme).
functions.php
<?php
// 1. PremiumPress reads its version from the active theme. Under a child theme
// that would be YOUR version, which breaks its cache refresh and language
// downloads. Pin it to the parent's version. (WordPress loads this file
// before the parent's, so this runs first.)
if (!defined('PPT_VERSION')) {
define('PPT_VERSION', (string) wp_get_theme(get_template())->get('Version'));
}
// 2. The parent does not load the child's style.css. Load it after the
// theme's own stylesheet (handle "ppt"), so your rules win.
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style(
'my-site-child',
get_stylesheet_uri(),
array('ppt'),
wp_get_theme()->get('Version')
);
}, 20);
// Your own functions and hooks go below.
Turning it on
- Finish setting up the main theme first: the setup wizard, your licence key and your design. These are stored in the database and carry over to the child.
- Upload the child folder to
wp-content/themes/. - Go to Appearance ▸ Themes and activate the child theme.
- Check the site front end and the admin, then make your changes in the child.
Good to know
- Raise the
Version:in your child'sstyle.csswhen you change its CSS, so visitors' browsers fetch the new file. - Theme updates install into the main theme's folder and never touch the child.
- For a handful of CSS rules you do not need a child theme: Appearance ▸ Customize ▸ Additional CSS is enough.
Was this page helpful?Still stuck? Contact support