在WordPress中,我首先尝试使用具有给定自定义分类的帖子修改循环,然后显示其他具有其他分类的帖子或不具有任何分类。
我需要在单个循环/ SQL查询中执行此操作,以便我可以设置偏移量并在页面上执行更多/分页。
这是我尝试过的SQL,但它返回一个重复列名称" term_taxonomy_id'错误:
SELECT *
FROM wp_posts AS wppost
INNER JOIN wp_term_relationships ON ( wppost.ID = wp_term_relationships.object_id )
INNER JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
AND wp_term_taxonomy.taxonomy = 'location'
AND wp_term_taxonomy.term_id
IN ( 1191 )
INNER JOIN (SELECT *
FROM wp_posts AS wppost
INNER JOIN wp_term_relationships ON ( wppost.ID = wp_term_relationships.object_id )
INNER JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
AND wp_term_taxonomy.taxonomy = 'location'
AND wp_term_taxonomy.term_id
NOT IN ( 1191 )) inn
ORDER BY wpost.post_date DESC
如何为'term_taxonomy_id'提供别名?在这种情况下?