Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
    
Worked like a charm, thanks! –  Roee Adler Apr 29 '11 at 8:35

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.

share|improve this answer
    
A redirect without an exit/die after or around it won't work. –  kaiser Jan 27 at 11:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.