WordPress.org

Ready to get started?Download WordPress

Forums

Change Page Tab order in header.php (2 posts)

  1. danclifton
    Member
    Posted 3 years ago #

    I'm using a theme called Celadon, which displays links to your Pages (minus any that you exclude in the theme's custom menu) as tabs at the top of the page. By default these are sorted alphabetically, but I'd like them to be sorted by page order instead. I've set the page order for each page, but I need to adjust the header.php to show them in this order. This is the section of code which I think is responsible for the tabs:

    <div id="navigation">
    		<ul>
    			<li<?php if (is_home()) {
    									echo " class=\"active_tab\"";
    								} elseif (is_single()) {
    									echo " class=\"active_tab\"";
    								}
    								?>><a href="<?php echo get_bloginfo('url') ?>">Home</a></li>
    			<?php
    			  $pages = get_pages();
    				$celadon_excluded_pages = explode(", ", $celadon_excluded_pages);
    			  foreach ($pages as $pagg) {
    					$page_title = $pagg->post_title;
    					if (!in_array($page_title, $celadon_excluded_pages)) {
    					  $link = '<li';
    						if (is_page($page_title)) {
    							$link .= " class='active_tab'";
    						}
    						$link .= '>';
    						$link .= '<a href="'.get_page_link($pagg->ID).'">';
    						$link .= $page_title;
    						$link .= '</a></li>';
    						echo $link;
    					}
    			  }
    			?>
    		</ul>
    	</div>

    I don't know much about PHP but have had a few stabs at it with no success. After reading the WordPress docs I was looking for 'sortcolumn=' where I could change the setting to 'menu_order', but this theme doesn't seem to have that.

    How can I change the tabs to be arranged by Page Order?

  2. danclifton
    Member
    Posted 3 years ago #

    resolved this by changing:

    $pages = get_pages()

    to

    $pages = get_posts ('orderby=menu_order&post_type=page');

    Solution from here: http://www.wptavern.com/forum/plugins-hacks/1355-get_pages-order.html

Topic Closed

This topic has been closed to new replies.

About this Topic