Page layouts
Page layouts
How PremiumPress builds its pages, and the supported ways to change them in code.
Copying a template into a child theme does not work
In many WordPress themes you can copy a file such as single.php into a child theme and edit it there. PremiumPress does not work that way. It loads its pages (the listing page, search results, the member area, login and sign-up, author profiles, events) from its own folders, so a copy in your child theme is never read.
Before reaching for a template, check whether a setting already does what you need. Most layout choices (which sections a listing page shows and in what order, the header and footer, the search filters, the homepage blocks) are admin settings or design choices.
Add to a page with hooks
The usual way to change a page is to add to it with an action, rather than replace it. For example, to put a notice under the title of every listing:
add_action('ppt_listing_after_title', function ($listingId) {
if (get_post_meta($listingId, 'my_flag', true)) {
echo '<p class="my-notice">' . esc_html__('Now taking bookings', 'my-site') . '</p>';
}
});
The full list of places you can hook into is in Hooks and filters.
Replace the listing page
The single listing page is the one template with its own switch. The ppt_single_template filter receives the path of the template PremiumPress is about to use, and you can return your own:
add_filter('ppt_single_template', function ($path, $themeType, $original) {
$mine = get_stylesheet_directory() . '/ppt/single-listing.php';
return is_file($mine) ? $mine : $path;
}, 10, 3);
Your file then draws the whole page, including get_header() and get_footer(). Start from a copy of the theme's own template and keep it up to date when the theme updates, because your copy will not receive its fixes.
Replace another page
No other page has a filter like this. To replace one (search results, for example), use WordPress's own template_include filter with a priority above 99, because the theme sets its pages at 99:
add_filter('template_include', function ($template) {
// The same test the theme uses for its search and category pages.
if (\Ppt\Directory\SearchPage::isListingContext($GLOBALS['wp_query'] ?? null)) {
$mine = get_stylesheet_directory() . '/ppt/search.php';
if (is_file($mine)) {
return $mine;
}
}
return $template;
}, 120);
For another page, change the condition to match it. Use this sparingly: a replaced page no longer gets the theme's improvements to it.
Header and footer
header.php and footer.php are standard WordPress templates, so a copy in a child theme does replace them. But they are thin wrappers that hand over to the theme's header and footer builder, and almost everything in them is set in Design ▸ Header & footer. Use the settings, or the ppt_after_announce and ppt_header_actions actions, rather than replacing the files.