🐞 fix: Make Services pages show the correct hero
Deploy to Dreamhost (dev) / build (push) Successful in 33s
Sync TODOs with Issues / sync_todos (push) Successful in 6s

This commit is contained in:
Keith Solomon
2026-07-05 13:28:25 -05:00
parent 36cf891659
commit d4a3e0a6c8
2 changed files with 2 additions and 62 deletions
+2 -1
View File
@@ -16,8 +16,9 @@ $headerLogo = getFieldValue( 'header.header_logo.url' ) ? getFieldValue( 'header
// The inner-page hero renders only on the Services page, its direct children,
// and its grandchildren. All other views (blog index, archives, single posts,
// search, 404) render without the hero.
$showHero = isServicesDescendant() && get_field( 'hero_style' ) === 'default';
$services = get_page_by_path( 'services' )->ID;
$showHero = $post->post_parent === $services ? true : false;
?>
<!DOCTYPE html>
-61
View File
@@ -77,67 +77,6 @@ function hasPageHeader() {
return true;
}
/**
* Bypass constant for the inner-page hero ancestor check.
*
* When `true`, `isServicesDescendant()` returns `true` for every page.
* Set this in test setup (e.g. in `wp-config.php` or a test bootstrap) so
* test fixture pages that are not Services descendants can still render
* the hero.
*/
if ( ! defined( 'CWC_TEST_BYPASS_HERO_GATE' ) ) {
define( 'CWC_TEST_BYPASS_HERO_GATE', false );
}
/**
* Checks if the current page is the Services page, a child of it, or
* a grandchild of it. Used to gate the inner-page hero.
*
* @param WP_Post|null $post The post to check. Defaults to the global `$post`.
* @param int|null $services_id Override the Services page ID. Defaults to
* the page with slug `services`.
*
* @return bool true if the post is the Services page or a descendant up to 2 levels.
*/
function isServicesDescendant( $post = null, $services_id = null ) {
if ( CWC_TEST_BYPASS_HERO_GATE ) {
return true;
}
if ( null === $post ) {
global $post;
}
if ( ! $post instanceof WP_Post ) {
return false;
}
if ( null === $services_id ) {
$services = get_page_by_path( 'services' );
if ( ! $services ) {
return false;
}
$services_id = (int) $services->ID;
}
$services_id = (int) $services_id;
if ( (int) $post->ID === $services_id ) {
return true;
}
if ( (int) $post->post_parent === $services_id ) {
return true;
}
$parent = get_post( $post->post_parent );
if ( $parent && (int) $parent->post_parent === $services_id ) {
return true;
}
return false;
}
/** Create the Owner role.
*
* This function creates a new role named "Owner" with all the capabilities of the