This the code I have currently and it’s functioning. I’d like to keep “$titlenamer” as the for the header area, despite what my edit below says. Can anyone help?
<?php
global $post;
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
}
if ($children) { ?>
<?php } ?>
This is the code I’m trying to achieve.
<?php
global $post;
if($post->post_parent) {
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
$menu_title = get_the_title($post->post_parent);
if($children) {
$menu_id = $post->ID;
$menu_title = $post->post_title;
}
else {
$menu_id = $post->post_parent;
$parent = get_post($menu_id);
$menu_title = $parent->post_title;
}
endif;
?>