0

i have a "Default Page Generator" on theme activation i have created...
in that file i set 'menu_order' for each page.

i want to exclude pages with menu order bigger then 50 from the default wp_list_pages menu

Is there a way to check for / retrieve 'menu_order' of each page? and if there is can you think of a way to intergrate it into the wp_list_pages function?

2

Declare the following function in your functions.php

function wpse58346_wp_list_pages( $pages, $r ) {
    foreach( $pages as $key => $page ) {
        if ( 50 < $page->menu_order )
            unset($pages[$key]);
    }
    return $pages;
}

Now before calling wp_list_pages() apply a filter as follows

add_filter('get_pages', 'wpse58346_wp_list_pages', '', 2);

And after you have called wp_list_pages() you can remove the filter so that it doesn't mess with some other funcctionality

remove_filter('get_pages', 'wpse58346_wp_list_pages');
  • gr8 job man... easy to implement and easy to use - thanks :) – Sagive SEO Aug 1 '12 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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