Forums

Auto display first subpage content on parent page (8 posts)

  1. natspace
    Member
    Posted 2 years ago #

    Hello.
    I want to auto load and output the content of the first subpages on the parent page when i click on the parent item.
    Can someone help me pls?
    Thanx.

  2. HorrorUK
    Member
    Posted 2 years ago #

    Do you mean just show a static page?

    That would just be done in Admin>> Settings>> Reading

  3. natspace
    Member
    Posted 2 years ago #

    No I want to load in automatic the content of the first subpage when i click on the parent page.
    Example:

    MAIN MENU: A B C

    Page A has 3 subpages: a b c

    When I click on main menu A link the content of subpage a is load in automatic and display.

  4. HorrorUK
    Member
    Posted 2 years ago #

    I'm not sure on that one, sorry

  5. danielsun
    Member
    Posted 2 years ago #

    ok this one shoul be easy. if it is not it is a fail.

  6. Oren Yomtov
    Member
    Posted 1 year ago #

    I am looking for a way to implement this functionality myself.

  7. bulhi
    Member
    Posted 1 year ago #

    i had the same problem and after a few google searches i found the solution here:

    http://www.wprecipes.com/wordpress-page-template-to-redirect-to-first-child-page

  8. MAS
    Member
    Posted 1 year ago #

    <?php
    if (have_posts()) {
      while (have_posts()) {
        the_post();
        if($post->post_parent){
            $my_subpage = new WP_Query(
                                      array('post_type' => 'page',
                                            'post_parent' => $post->ID,
                                            'post_status' => 'publish'));
            while($my_subpage->have_posts()): $my_subpage->the_post();
              ///Now put your code here according to your design
            endwhile;
         }
      }
    }

    If solve, mark it as resolve

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags