When creating a query with wpdb exclude IDs are missing
-
Hi,
I had to make a query with wpdb and this is the query:
$sql = " SELECT * FROM {$wpdb->prefix}posts as p INNER JOIN {$wpdb->prefix}postmeta as pm ON p.ID = pm.post_id WHERE 1=1 AND pm.meta_key = 'subtitle' AND ( p.post_title LIKE '%".$s."%' OR p.post_content LIKE '%".$s."%' OR p.post_excerpt LIKE '%".$s."%' OR pm.meta_value LIKE '%".$s."%' ) AND p.post_status = 'publish' AND p.post_type IN ('insurance') AND p.post_type NOT IN ('revision') ORDER BY p.post_title LIKE '%".$s."%' ASC ";The only way to exclude ID is adding by hand like this:
AND p.ID NOT IN (1500,1498,1496,1492,1490,1485,1482,98,100,1494,2,744,1063,1280,1618,254,1581)Is there any way to get this array from the plugin ? so then I would concatenate to my query.
Many thanks in advance.
Regards
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘When creating a query with wpdb exclude IDs are missing’ is closed to new replies.