WordPress query to fetch the posts

<?php
 global $wpdb;
 $querystr = " SELECT distinct(post_title) ,ID,post_title FROM $wpdb->posts
 WHERE post_type='post'  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 *