Thread Starter
ywftdg
(@ywftdg)
I have even tryed using a custom query, and the mysql LIKE feature does not work.
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'tag'
AND wpostmeta.meta_value LIKE 'art%'
AND wposts.post_status = 'publish'
AND wposts.post_type = 'post'
ORDER BY wposts.post_date DESC
";
What is the deal with LIKE not working?
Thread Starter
ywftdg
(@ywftdg)
Bump: nobody out there ever had to query wordpress database using LIKE?
i dont know too much about this stuff, i just started querying the worpress db, but i copied you query to test and i needed to change the table name to “wp_posts” and “wp_postmeta”
Fairly simple… This should do the trick.
"SELECT " . $wpdb->prefix . "posts.* FROM " . $wpdb->prefix . "posts JOIN " . $wpdb->prefix . "term_relationships ON " . $wpdb->prefix . "posts.id = " . $wpdb->prefix . "term_relationships.object_id LEFT JOIN " . $wpdb->prefix . "terms ON " . $wpdb->prefix . "term_relationships.term_taxonomy_id = " . $wpdb->prefix . "terms.term_id WHERE " . $wpdb->prefix . "terms.name != 'nsfw' AND " . $wpdb->prefix . "terms.name = 'art' AND " . $wpdb->prefix . "posts.post_status = 'publish' AND " . $wpdb->prefix . "posts.post_type = 'post' GROUP BY " . $wpdb->prefix . "posts.id"