How to exclude content (and other returned values) from WP_query()?

Like a commented the only way to do it is with a custom sql query so:

global $wpdb;
$mypages = $wpdb->get_results( "SELECT post_title, post_name FROM $wpdb->posts
 WHERE post_type="page" 
 AND post_status="publish" 
 AND parent="0"");

if (count($mypages) > 0){
    foreach ($mypages as $page){
        //do you stuff
        //$page['post_title'] for title
        //$page['post_name'] for slug
    }
}

Leave a Comment