• Hello all

    I’m fairly new to WordPress but have been programming since the 90s.

    I’ve got a parent page with 2 child pages. I want to display the parent page url from the child page.

    I’ve tried the code shown in https://www.ads-software.com/support/topic/fatal-error-while-trying-to-get-parent-page-permalink?replies=3 because it seemed pretty reasonable.

    Unfortunately, it behaved exactly like the poster described and did NOT return the parent page url. I had been hoping it was some kind of weird glitch and that I’d get lucky.

    So, the question is, when I am displaying a child page what php code can I add to display the parent page url?

    Thanks

    Mark

Viewing 1 replies (of 1 total)
  • This is what I use:

    <?php if ( $post->post_parent ) { ?>
        <a href="<?php echo get_permalink( $post->post_parent ); ?>" >
            <?php echo get_the_title( $post->post_parent ); ?>
        </a>
    <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘how do you get parent page url?’ is closed to new replies.