function getMcClellandPageParentName($post) { if (empty($post->post_parent)) { return get_the_title($post->ID); } else { return getMcClellandPageParentName(get_post($post->post_parent)); } }
<?php echo $submenu; ?> </div> </div> <?php } ?> </nav><!-- .entry-header --> <div class="entry-content clearfix"> <?php the_content(); ?> <?php wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'mcclellandinsurance'), 'after' => '</div>')); ?> </div><!-- .entry-content --> <footer class="entry-footer"> <?php edit_post_link(esc_html__('Edit', 'mcclellandinsurance'), '<span class="edit-link">', '</span>'); ?> </footer><!-- .entry-footer --> </article><!-- #post-## --> <div id="content-cursor" data-post-parent="<?php echo getMcClellandPageParentName($post, true); ?> "></div>
get_header(); $employeeQuery = new WP_Query(['posts_per_page' => -1, 'post_type' => 'partner', 'order' => 'ASC']); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ($employeeQuery->have_posts()) { ?> <div class="content-box our-team"> <nav class="clearfix page-heading"> <h2 class="entry-title"> <span class='desktop'><?php echo getMcClellandPageParentName($post); ?> </span> <span class='mobile'><?php echo the_title(); ?> </h2> <?php $submenu = wp_nav_menu(["menu" => getMcClellandMenuName($post), "submenu" => getMcClellandMenuName($post, false), "link_before" => "<span>", "link_after" => "</span>", "echo" => 0]); if (!$submenu && wp_get_nav_menu_object(getMcClellandMenuName($post))) { $submenu = wp_nav_menu(["menu" => getMcClellandMenuName($post), "link_before" => "<span>", "link_after" => "</span>", "echo" => 0]); } ?> <?php if ($submenu) { ?>
function getMcClellandPageParentName($post, $asLowerCase = false) { if (empty($post->post_parent)) { $title = get_the_title($post->ID); return $asLowerCase ? str_replace(" ", "-", strtolower($title)) : $title; } else { return getMcClellandPageParentName(get_post($post->post_parent), $asLowerCase); } }