Use can this code snippet in a multitude of ways. I mostly use it inside while loops to get parent data or for breadcrumb navigation.
Here’s a PHP and HTML hybrid solution:
<?php if($post->post_parent) : ?>
<a class="parent-page-title" href="<?php echo get_permalink( $post->post_parent ); ?>"><?php echo get_the_title( $post->post_parent ); ?></a>:
<?php endif ?>
Pretty simple huh? Here’s a full PHP version:
<?php if($post->post_parent) :
echo ' <a class="parent-page-title" href=" ' . get_permalink( $post->post_parent ) . ' "> ' . get_the_title( $post->post_parent ) . '</a>';
endif ?>
post_parent) : ?>
post_parent ); ?>”>post_parent ); ?>:
Hi this is great!