WordPress.org

Support

Support » Plugins and Hacks » Show a link to the main page on subpages

Show a link to the main page on subpages

  • 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/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author webvitalii

    @webvitaly

    Try to add this code:

    <?php
    echo '<a href="'.get_permalink( $post->post_parent ).'">';
    echo get_the_title( $post->ID );
    echo '</a>';
    ?>

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show a link to the main page on subpages’ is closed to new replies.