WordPress query to fetch the pages

<?php
 global $wpdb;
 $querystr = " SELECT distinct(post_title) ,ID,post_title FROM $wpdb->posts
 WHERE post_type='page'  AND post_status='publish' ";
 $pageposts = $wpdb->get_results($querystr, OBJECT);
?>
Share

Leave a Reply

Your email address will not be published. Required fields are marked *