• A while back on a previous WordPress site I set up I used this code to redirect my main-nav to my first sub-nav link.

    <?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));
      }
    }
    ?>

    I’m using this same code on a new site, but it’s not working as intended. For example, it appears that it redirects to the lowest page ID instead of directing to the menu sort order. Any ideas why this would be happening?

    Thanks,
    Burt

Viewing 1 replies (of 1 total)
  • Thread Starter get_username

    (@get_username)

    Ok, so this doesn’t work based on my order as seen in the Menu admin panel, but oddly enough, if I add a number to the Page Attributes it does work. What is the difference between Page Attributes Order, and the Menus panel? Like I said, I have another site that uses this and all of the pages Page Attributes are set to zero (0). Can anyone offer some help?

    [ Please do not bump, that’s not permitted here. ]

Viewing 1 replies (of 1 total)
  • The topic ‘Page redirect going to wrong page’ is closed to new replies.