Query string which does not work
-
I need to list posts starting with letter ‘$letter’:
$results = $wpdb->get_results("SELECT * FROM wp_posts p JOIN wp_term_relationships r ON r.object_id = p.ID JOIN wp_terms terms ON terms.term_id = t.term_id WHERE terms.name IN ('cat1', 'cat2', 'cat3') AND p.post_status = 'publish' AND p.post_title LIKE '$letter%' ");This query returns NOTHING. When I remove the POST TITLE LIKE… clause, it returns what it should, but I do need that clause because I just want posts that begin with given letter.
What is wrong with my query string?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Query string which does not work’ is closed to new replies.