I have the following query that bring the posts that contain a specific word in the title
SELECT posts_post.ID AS post_ID,
posts_post.post_date AS post_post_date,
CONCAT('<a href="',posts_post.guid,'">',posts_post.post_title,'</a>') AS post_title_with_link_to_post
FROM wp_posts AS posts_post
WHERE 1=1
AND posts_post.post_title LIKE '%HOTARAR%'
AND posts_post.post_type = 'post'
GROUP BY post_post_date
The problem now is that I need to bring the posts only from a specific category (tag slug for the category is hotarari-consiliu-local and has the ID 160), how could I modify the above query to bring posts only from a single blog posts category? Thanks!
2
Answers
Try the below query.
Assuming Bhautik is on the right path, then something like this should work (I don’t know where ‘hotarari-consiliu-local’ belongs in this).