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


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?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: