How do I retrieve data as a Wp_query object with this custom mysql query?

SELECT IF (POSITION('Villa' IN p.post_title )>=1, SUBSTRING(p.post_title, 7), post_title) AS 'Title', p.post_title, p.ID, p.post_content from wp_posts p INNER JOIN wp_term_relationships tr ON p.ID=tr.object_id where tr.term_taxonomy_id=4 and p.post_status='publish' ORDER BY Title ASC
I can run above query to get data with “wpdb” function like

$wpdb->get_results($query);

But I need the above results to be returned as a Wp_query object as i want to use functions like get_the_excerpt()

Read more here: How do I retrieve data as a Wp_query object with this custom mysql query?

Leave a Reply

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