You can use something like this to get the parent page URL (and show its page title):
<?php if ( $post->post_parent ) { ?>
<a href="https://wordpress.stackexchange.com/questions/192895/<?php echo get_permalink( $post->post_parent ); ?>" >
<?php echo get_the_title( $post->post_parent ); ?>
</a>
<?php } ?>
If you are running this code outside of the loop (thanks @BorisKuzmanov), then use this:
<?php global $post;
if ( $post->post_parent ) { ?>
<a href="https://wordpress.stackexchange.com/questions/192895/<?php echo get_permalink( $post->post_parent ); ?>" >
<?php echo get_the_title( $post->post_parent ); ?>
</a>
<?php } ?>
Related Posts:
- Parent/child pages and link structure the right way
- Why is there a link tag with rel “profile” pointing to gmpg.org?
- How can I link to the most recent post in a category?
- Is it possible to link to draft pages?
- How to use wp_rel_nofollow to add nofollow to external links only?
- Is there any way to set default for “Insert/Edit Link” to “Open link in new window”?
- How to splice in wp_links links into the loop?
- widget to output a link to archive view
- Is there an easy way to create a links index page?
- How do I remove or disable “Or link to existing content” in “insert link” dialogue?
- Retrieving all Links from a Post?
- Open link in a new tab checked by default when adding a new link in visual post editor
- Generate Random Post Links Somewhere in the post
- Getting only the most recent bookmark?
- Plugin that inserts favicon next to links
- Create anchor from Wysiwyg editor
- Get post / page ID from ACF Link field
- Can I generate then display a mixed list of linked and unlinked terms
- Make page tab link to pdf
- How to change server name on WordPress Installation?
- Plugin for wikipedia style references in WP?
- Problem creating an edit link for a custom post type
- Automaticly replace a link with other “new link”
- How to add a WordPress page with multiple picture links?
- Enumerating over a category of links
- Links in nonalphabetic order
- Copy button for anchor link
- How to automatically nofollow a set domains? (I seem to have half of the answer)
- My custom link works only on home page
- Read more link to external webpage
- How to apply default post categories to link manager plugin
- How to change all external links to “nofollow” but only for Contributor role?
- Is there anyway to use relative link instead of absolute link?
- How do I hide the ‘Edit’ link in publshed posts
- Do you use links?
- WP Method `get_theme_file_uri()` Doesn’t Seem To Be Working Properly When Used In The Head Section Of A Site
- how do I get rid of the links and all the links related menu items on the admin ui?
- How to deal with internal links in blog while developing new site in WordPress?
- Remove nofollow from specific internal links
- How to remove massive link in WordPress content
- Delete all href attribute in WordPress posts
- Alternative to rb-internal-links to implement [intlink tag?
- Allow insecure embedded content in a SSL secured website
- How to prevent WordPress from abbreviating long slugs?
- Highlight archive link on single.php
- Dynamic logo/banner depending on affiliate link
- Put password on a wordpress link in a article
- Disable title link in the backend for non-admins
- Add class to all links created by tinyMCE
- How do i remove all Bit.ly shortened links from site?
- how do I turn off whatever causes links to be embedded as URL’s site title
- How to make entire in blog post page linked?
- How to make a random dynamic url?
- WordPress does not show correct page
- Bulk change link to pdf’s
- How can I automatically display the section link on my one-page Elementor website?
- White image when I share my site
- How to track which users click link/button?
- Disable automatic embed links
- How to add a column into the link manager?
- How can I get the url from file uploaded in Media Library
- Getting duplicate homepage links | Even if there is only one page in Dashboard Please Help
- Rotate prefix for external domain links using functions.php?
- How to change the canonical link from a category or taxonomy archive?
- Add Developer Link on Homepage Only
- How to mask external download links to be only accessible by logged-in users?
- Content -> Post is easy, but Post -> Content is hard
- How to use the WordPress API to get links and scripts in and
- Metallex Theme modifies links after saving them
- Get youtube link title in post title
- bloginfo(); outputs wrong urls without https on inner pages
- How can I add a sortable link_updated column to the Link Manager?
- how to display country/region/subject/post reasonably
- Unwanted Autogenerated Link
- Links open when scrolling on touch devices/mobile
- Site migration and how to write internal links with migration in mind
- List pages including both parent and child pages
- Remove all link title attributes
- How do I change the “href” link that corresponds with an “li class” statement?
- Unable to create hyperlink after WordPress updated
- Anchor doesn’t work if it’s given in the url
- Links offset on my page
- random characters on links
- Detect what page was linked-from
- link header to homepage (for wp multisite)
- insert link in wordpress editor greyout whole screen?
- permalink and $_GET
- What is the right way to code links for WordPress pages?
- pictures does not apeare in posts
- remove the ‘page’ URL parameter in previous/next posts link
- Internal linking search box not working – WP 3.2
- Blogroll import/export with categories and descriptions
- WordPress: How to make a subsubdirectory
- External Links Not Working [closed]
- Access the article edit page from the web address bar?
- Is there any way to display the link of a WordPress page without relying in its slug (or full path)?
- Link to blogg-page
- Is it posibble to have alink to display all posts on index.php?
- I’ve been trying for an hour to remove the underline from links; I don’t understand why something that should be so simple is so difficult [closed]
- gallery link not displaying photos