• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to get parent page link?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › How to get parent page link?

This topic is: resolved

Tagged: pagination, Subpages navigation

  • This topic has 2 replies, 2 voices, and was last updated 7 years, 6 months ago by Cesare Gilento.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 28, 2018 at 2:37 am #219351
    Cesare Gilento
    Participant

    Good morning,

    I'm trying to add a parent page link to the bottom navigation without using plugins.

    For posts I've been able to output the first category link with the following code:

    
    $category = get_the_category();
    $category_markup = '<div class="pagination-up floatleft aligncenter"><a href="' . get_category_link( $category[0]->term_id ) . '">&uarr; ' . $category[0]->cat_name . '</a></div>';
    if( $category[0] ) {
        echo $category_markup;
    }

    Here's an example: https://www.cesaregilento.it/2018/02/01/top-of-the-world/

    I'd like to achieve a similar result with pages. For example, if the page has a parent page, I'd like to output the link to the parent page. If the page hasn't a parent, I'd like to output the homepage link.

    Is it possible without the use of plugins?

    April 28, 2018 at 6:34 am #219355
    Victor Font
    Moderator

    Assuming you're in the loop:

    if ( $post->post_parent ) {
     $parent = '<a href="' . get_permalink( $post->post_parent ) .'">' . get_the_title( $post->post_parent ) . '</a>';
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    April 28, 2018 at 12:29 pm #219364
    Cesare Gilento
    Participant

    Thanks indeed, Mr. Font.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble