Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this code in a site that I am trying to understand. I don't get exactly what it does. I get some of it but not all

  $nav_posts = $wpdb->get_results( "SELECT id FROM $wpdb->posts WHERE post_type =  'nav_menu_item' and post_status = 'publish' ORDER BY menu_order ASC" );
 $exclude = $base_pages = array();

foreach($nav_posts as $nav) {

    $_menu_item_object = get_post_meta($nav->id,'_menu_item_object',true);

    $post_status = get_post_status( get_post_meta($nav->id,'_menu_item_object_id',true) );

    if($_menu_item_object=='page' && $post_status=='publish') {

        $exclude[] = $_menu_item_object_id = get_post_meta($nav->id,'_menu_item_object_id',true);

        $base_pages[] = get_post($_menu_item_object_id); 

    }

}

$second_pages = get_pages(array('exclude'=>$exclude));

$pages = array_merge($base_pages,$second_pages);
share|improve this question
Check the documentation of anything you don't understand, e.g.: $wpdb , foreach etc... – brasofilo Dec 29 '12 at 21:28

closed as too localized by toscho Dec 29 '12 at 17:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.