I'll now suicide if i cant find this.. it has taken my whole day to sort this out Problem Wordpress Page sorting in header.php of my theme the only code i found out in the whole template regarding page menu is in the header.php <div id="menu"> <ul> <li><a <?php if (is_home()) echo "class=\"active\""; ?> href="<?php bloginfo('url'); ?>"><span>Home</span></a></li> <?php $pages = get_pages(); if ($pages) { foreach ($pages as $page) { $page_id = $page->ID; $page_title = $page->post_title; $page_name = $page->post_name; if ($page_name == "archives") { (is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="active"':$selected=''; echo "<li><a".$selected." href=\"".get_page_link($page_id)."\"><span>Archives</span></a></li>\n"; } elseif($page_name == "about") { (is_page($page_id))?$selected = ' class="active"':$selected=''; echo "<li><a".$selected." href=\"".get_page_link($page_id)."\"><span>About</span></a></li>\n"; } elseif ($page_name == "contact") { (is_page($page_id))?$selected = ' class="active"':$selected=''; echo "<li><a".$selected." href=\"".get_page_link($page_id)."\"><span>Contact</span></a></li>\n"; } elseif ($page_name == "about_short") {/*ignore*/} else { (is_page($page_id))?$selected = ' class="active"':$selected=''; echo "<li><a".$selected." href=\"".get_page_link($page_id)."\"><span>$page_title</span></a></li>\n"; } } } ?> </ul> </div> PHP: Right now the pages are sorted in the menu by name. I simply want them to be sorted on page ID or page Order basis Guys please help me out on this
If you are trying to put your pages in a certain order you can use this plugin called My Page Order: http://geekyweekly.com/mypageorder
thats a horrible way to get your menu. <?php wp_list_pages('sort_column=menu_order'); ?> That will do it for you and put it in page order not by name.
couldnt agree more buddy.. i didnt wrote this theme and i never wanted to use such theme.. but the theme itself looks great.. ill try your way but right now i dont think so it will work coz the theme guy wrote all this shit to highlight a selected page.. any more gurus around?
well, here you go.. am a guru myself.. posting here coz it may help other guys.. all i had to do was.. change this $pages = get_pages(); if ($pages) { foreach ($pages as $page) { PHP: to, this; $pages = get_pages('sort_column=menu_order'); if ($pages) { foreach ($pages as $page) { PHP: wordpress tags can be tricky..