Directing a page to a default subpage

I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I’d like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is:

1. Movies
1.1 General
1.2 Westerns
1.3 Animated
2. Music
2.1 General
2.2 Classic
2.3 Country

What I want is that when someone clicks on “Movies” he will reach “Movies/General”. Can this be achieved using plugins alone? If not, what’s required?

Related posts

Leave a Reply

3 comments

  1. Using WordPress custom nav menus create a menu and add the “General” page 2 times. The first as the parent and the second as the first child then add the rest of the pages as childs under the first General.

    Change the title in the first general to movies then on the front end when a user clicks movies they will got to the general page.

    enter image description here

  2. The following worked like a charm, and better than the answer above. The problem with the answer above is that when viewing sub-sub-pages it was suddenly not possible to highlight the top menu section simply with css. With this solution you can keep the menu as it actually is. (http://www.wprecipes.com/wordpress-page-template-to-redirect-to-first-child-page)

    To achieve this recipe, you have to create a page template. Create a new file and paste the following code in it:

    <?php
    /*
    Template Name: Redirect To First Child
    */
    if (have_posts()) {
      while (have_posts()) {
        the_post();
        $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
        $firstchild = $pagekids[0];
        wp_redirect(get_permalink($firstchild->ID));
      }
    }
    ?>
    

    Save the file under the name redirect.php and upload it to the wp-content/themes/your-theme directory of your WordPress install. Once done, you can use the page template.

  3. I did it in a more simple way than above.

    Create a custom link. For the URL make it the URL of the “default” sub page you want it to be and the put the link text as whatever the page is that you want it to be called.

    For your case above it would be URL http://www.yourwebsite.com/General and link text ‘Movies’

    If you want the default to go to Westerns then you would put the URL as http://www.yourwebsite.com/Westerns and the link text as ‘Movies’.

    Doing this will allow you to click on the parent page ‘Movies’ and direct you to General or Westerns respectively.