WordPress.org

Ready to get started?Download WordPress

Forums

Page-list
Show a link to the main page on subpages (3 posts)

  1. Pepozzo
    Member
    Posted 1 year ago #

    Hello!

    I'm using a code that you suggest me:

    <?php
    $children = get_pages('child_of='.$post->ID);
    if( count( $children ) != 0 ) {
    	echo do_shortcode('[subpages]');
    } else {
    	// no subpages
    }
    ?>

    That works perfectly, but I would like to ask if is possible to show, on subpages, a link to the "main" page.
    I mean, i've this structure:
    - Product 1
    -- Description
    --- Requirements

    Is it possible to create a link to "Product 1" in each subpage (Description and Requirements)?

    Thanks!

    http://wordpress.org/extend/plugins/page-list/

  2. webvitaly
    Member
    Plugin Author

    Posted 1 year ago #

    Try to add this code:

    <?php
    echo '<a href="'.get_permalink( $post->post_parent ).'">';
    echo get_the_title( $post->ID );
    echo '</a>';
    ?>
  3. Pepozzo
    Member
    Posted 1 year ago #

    Thank you for your fast reply.

    That code works fine, but i was thinking about linking directly to the main parent page (if is it possible, of course).

    Also, is it possible to show that link only if a parent page is present?

    Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.