我试图仅显示具有自定义meta_key"my_metakey"的帖子的结果,该文件也不应为空。
我试图修改 sphinx.conf 文件中的sql_query,但没有运气。
我不熟悉狮身人面像使用 sphinx.conf 文件的方式,所以不确定需要多少次编辑才能实现这一点。
我正在使用的插件是 https://wordpress.org/plugins/wordpress-sphinx-plugin/
任何帮助都是高度适当的!
经过大量测试,我通过在 sphinx.conf 文件中修改源 {prefix}main_posts{} 的 SQL 查询来完成我想要的东西,如下所示:
sql_query = select
p.ID*2+1 as ID,
0 as comment_ID,
p.ID as post_ID,
p.post_title as title,
p.post_content as body,
t.name as category,
my_metakey_meta.meta_value as my_metakey,
.
.
.
from
{wp_posts} as p
left join
{wp_term_relationships} tr on (p.ID = tr.object_id)
.
.
left join
wp_postmeta my_metakey_meta on (p.ID = my_metakey_meta.post_id and my_metakey_meta.meta_key = 'my_metakey')
.
.
.
where
p.id>=$start AND p.id<=$end and
p.post_status = 'publish' and
my_metakey_meta.meta_value != ''
group by p.ID
并修改了源 {前缀}main_comments{} 的 SQL 查询如下:
sql_query = select
.
.
'' as category,
'' as my_metakey,
.
.
.