最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wpdb - Counting Posts with multiple taxonomy and terms condition using MySQL and AJAX

programmeradmin3浏览0评论

I am trying to get the number of posts with multiple taxonomy and terms using MySQL and AJAX. but I cannot get the desired result with my query. I derived my query in this wpdb query and sadly it returns 0. I am hoping anyone can give me the exact sql query for this one. very much appreciated.

Here is my current Query:

SELECT p.post_title, p.post_content
FROM wp_posts AS p
INNER JOIN wp_term_relationships AS tr ON ('p.ID' = tr.object_id)
INNER JOIN wp_term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
INNER JOIN wp_terms AS t ON (t.term_id = tt.term_id)
WHERE   p.post_status = 'publish' 
    AND p.post_type = 'company'
    AND tt.taxonomy = 'repair_duration' 
    AND t.name = 'days'
ORDER BY p.post_date DESC

this one is for a single condition, and I am trying to achieve searching with multiple values of terms. I tried using WHERE IN but still no luck.

Example: Search A company that has taxonomy of repair_duration and terms of day, minutes and has taxonomy of repair_quality and terms of good, best

I really appreciate your responses. currently I am working on wpdb query on ajax, if that's possible.

发布评论

评论列表(0)

  1. 暂无评论