Not possible?
Wrong forum?
Thanks :o)
A bit late, I know, but you could try adding something along the lines of:
<?php if($post->post_parent) {
$parent_link = get_permalink($post->post_parent); ?>
<a href="<?php echo $parent_link; ?>">Link to parent page</a>
<?php } ?>
to your template file.
That was just the solution I was looking for. Thank you flashaaron!
Thanks flash! You did a good thing to post the solution in a google-able topic. 🙂
So extremely useful flashaaron!
Use in combination with information from this page:
http://wordpress.org/support/topic/160732?replies=5
Replace “Link to parent page” in the above code with the code below to specifically call whatever the parent’s name is:
<?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
Thanks flashaaron!
I was creating all the other sub-page navigation links manually in a list since i’m not great with wordpress loops yet. Then I ran into problems linking back to the parent page, because it would have double the permalink e.g. creatine_guide/creatine_guide :p
Thanks very much for the bit of wordpress code, saved me hours of searching.
For the benefit of other users…. I stumbled upon a small problem with the earlier code. On the child pages, the parent page link appears. However, on the parent page itself, it’s not there!
I finally worked it out by repeating the echo parent link part:
<?php if($post->post_parent) {
$parent_link = get_permalink($post->post_parent); ?>
<a href="<?php echo $parent_link; ?>">Main</a>
<?php }
else { ?> <a href="<?php echo $parent_link; ?>">Main</a>
<?php }
?>
At least it worked for my system, where I only had 1 parent page. Hope this is useful for others 🙂
I just added to this code so it grabs the parent page’s title and dynamically changes the link per page.
<?php if($post->post_parent) {
$parent = $wpdb->get_row("SELECT post_title FROM $wpdb->posts WHERE ID = $post->post_parent");
$parent_link = get_permalink($post->post_parent); ?>
<a href="<?php echo $parent_link; ?>">Back to <?php echo $parent->post_title; ?></a>
<?php } ?>
This may be off topic, but if you’re hoping to use this display a breadcrumb type list – this post is very helpful in doing so:
http://wordpress.org/support/topic/179226?replies=13
Also, here is some available codes for $post:
http://wordpress.org/support/topic/168285