get parent page link wordpress
To get the parent page link in WordPress, you can use the following code:
<?php
$parent_link = get_permalink( $post->post_parent );
echo '<a href="' . $parent_link . '">Parent Page</a>';
?>
This code retrieves the parent page link in WordPress by first obtaining the parent page ID using $post->post_parent
, and then using the get_permalink
function to get the permalink of the parent page. Finally, the link is echoed out with an anchor tag.