Support » Fixing WordPress » Need to link to Parent Page from Child outside of Loop

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try this something like this:

    <?php $ancestors = get_post_ancestors($post);
    $parent = $ancestors[0];
    $parent_link = get_permalink($parent);
    $parent_title = get_the_title($parent); ?>
    <a href="<?php echo $parent_link; ?>"><?php echo $parent_title; ?></a>

    This worked great… however, this website is using AJAX so it is only loading the home page when I start at the site’s home. If I refresh the site, it will start from whichever page I’m on and serve that as the parent.

    Is there any way that I could work around the restrictions of AJAX and the lack of refreshing?

    AJAX is outside of my realm of experience, so I can’t be much help there. Perhaps someone else will chime in.

    Thank you, Krissie.

    The issue seems to be that whichever page makes the AJAX request, it will keep that URL. Unfortunately, I can’t seem to get it to work. I hope someone can provide some guidance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need to link to Parent Page from Child outside of Loop’ is closed to new replies.