Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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');
share|improve this answer
    
gr8 job man... easy to implement and easy to use - thanks :) –  Sagive SEO Aug 1 '12 at 21:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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