Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created June 29, 2011 21:59
Show Gist options
  • Save mattboon/1055120 to your computer and use it in GitHub Desktop.
Save mattboon/1055120 to your computer and use it in GitHub Desktop.
WordPress Generate Navigation
<?php
global $root_page_id;
if (!empty($post->ancestors)) { $root_page_id = $post->ancestors[(count($post->ancestors)-1)]; } else { $root_page_id = $post->ID; }
// get root page id
global $excluded_pages_string;
global $excluded_pages_array;
$excluded_pages_string = "";
$excluded_pages_array = explode(",", $excluded_pages_string);
// exclude confirmation etc. pages
global $primary_nav_items;
$primary_nav_items = array ("6", "7", "8", "9", "10", "11", "12", "13");
// list primary sections
?>
<?php foreach($primary_nav_items as $level_one) : ?>
<?php $level_two = get_pages('child_of='.$level_one.'&parent='.$level_one.'&sort_column=menu_order&sort_order=asc&exclude='.$excluded_pages_string.'');?>
...
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment