Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress对帖子的查询正在将修订作为结果_Php_Mysql_Wordpress - Fatal编程技术网

Php Wordpress对帖子的查询正在将修订作为结果

Php Wordpress对帖子的查询正在将修订作为结果,php,mysql,wordpress,Php,Mysql,Wordpress,我有下面的wordpress查询,它多次显示文章标题,我已经检查过了,它得到了每个文章的所有修订 以下是查询: SELECT DISTINCT post_title, ID FROM wpblog_posts WHERE post_title LIKE '%Kimberley%' OR post_title LIKE '%Camping%' AND wpblog_posts.post_type = 'post' AND post_status = 'publish' ORDER BY

我有下面的wordpress查询,它多次显示文章标题,我已经检查过了,它得到了每个文章的所有修订

以下是查询:

SELECT DISTINCT post_title, ID 
FROM wpblog_posts 
WHERE post_title LIKE '%Kimberley%' 
OR post_title LIKE '%Camping%' 
AND wpblog_posts.post_type = 'post' 
AND post_status = 'publish' 
ORDER BY post_title DESC LIMIT 0, 6;
任何人都知道为什么会这样

更新

从查询字符串中删除为不相关,并将使其 更容易调试

LEFT JOIN wpblog_term_relationships rel ON rel.object_id = wpblog_posts.ID 
LEFT JOIN wpblog_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id 
LEFT JOIN wpblog_terms t ON t.term_id = tax.term_id

干杯

检查此查询是否适合您:

SELECT DISTINCT post_title, ID 
FROM wpblog_posts 
WHERE (post_title LIKE '%Kimberley%' OR post_title LIKE '%Camping%')
AND wpblog_posts.post_type = 'post' 
AND post_status = 'publish' 
ORDER BY post_title DESC LIMIT 0, 6;

查询正在查找诸如“%Kimberley%”之类的帖子-任何类型的帖子或类似“%Camping%”和wpblog_posts.post_type='post'..

。很有效:D谢谢你的帮助,非常感谢。