• I am using the below code in my nav. It works perfectly at showing me the top level parent of the page no matter what subpage I am on. The only issue I am having is making it a link back to that page. Can someone tell me what to do to make it link back… I am a php newbie but I am a master cut and paster. Thanks

    <div id="sideNavParent">
    	<?php
    if($post->post_parent) {
    $ancestors = get_post_ancestors($post->ID);
    $root = count($ancestors)-1;
    $parent = $ancestors[$root];
    $parent_title = get_the_title($parent);
    echo $parent_title;
    } else {
    wp_title('');
    }
    ?>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter arrowoods

    (@arrowoods)

    you can view an example here. http://www.franklinchristianchurch.com/groups I want groups to be clickable and link to the groups page so when you are on child pages you can get back to it.

    Thread Starter arrowoods

    (@arrowoods)

    Well I found my own solution, and anyone else who needs it here it is.

    <?php
    if($post->post_parent) {
    $ancestors = get_post_ancestors($post->ID);
    $root = count($ancestors)-1;
    $parent = $ancestors[$root];
    $parent_title = get_the_title($parent);?>
    <a href="<?php echo get_permalink($parent) ?>"><?php echo $parent_title;?></a>
    <?php
    } else {
    wp_title('');
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Linking to parent… HELP!!’ is closed to new replies.