fix: extend Kadence title-section hide to all pages with title:hide meta

Add a dynamic wp_head hook that reads _kadence_post_layout per page and injects
page-scoped CSS to hide .entry-hero.page-hero-section and remove boxed content
styling whenever title:hide or layout:fullwidth is set. Targets page-id-{N} so
it does not affect legal pages that intentionally show the Kadence title banner.
MU-plugin bumped to v1.3.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malin
2026-05-19 20:46:55 +02:00
parent 430defd55f
commit 0e036366dd

View File

@@ -87,6 +87,32 @@ if (!defined('WP_POST_REVISIONS')) {
define('WP_POST_REVISIONS', 3);
}
// --- Global: hide Kadence title section on pages with custom heroes ---
// Kadence free ignores _kadence_post_layout title:hide meta.
// We read it ourselves and output the fix for any page that set it.
add_action('wp_head', function () {
if (is_singular()) {
$layout = get_post_meta(get_the_ID(), '_kadence_post_layout', true);
$meta = $layout ? json_decode($layout, true) : [];
$hide_title = isset($meta['title']) && $meta['title'] === 'hide';
$full_width = isset($meta['layout']) && $meta['layout'] === 'fullwidth';
if ($hide_title || $full_width) {
$rules = [];
if ($hide_title) {
$rules[] = '.page-id-' . get_the_ID() . ' .entry-hero.page-hero-section{display:none!important}';
}
if ($full_width) {
// Remove boxed content wrap styling added by content-style-boxed body class
$rules[] = '.page-id-' . get_the_ID() . ' .entry-content-wrap{padding:0!important;box-shadow:none!important;margin:0!important;background:none!important}';
$rules[] = '.page-id-' . get_the_ID() . ' .content-area{max-width:100%!important;padding:0!important}';
}
if ($rules) {
echo '<style id="acrib-page-fixes-' . get_the_ID() . '">' . implode("\n", $rules) . '</style>' . "\n";
}
}
}
}, 5);
// --- Homepage: inject critical CSS fixes ---
add_action('wp_head', function () {
if (!is_front_page()) return;