gpt4 book ai didi

php - Wordpress 分类查询中的 double

转载 作者:行者123 更新时间:2023-11-29 22:48:59 26 4
gpt4 key购买 nike

我从这个 wordpress 查询中得到了 double :

SELECT LEFT(main.post_title , 1) AS `character`,
main.post_title AS title,
main.post_content AS content,
parent_data.name AS parent_title,
root_data.name AS root_title,
thumbnail_data.meta_value AS thumbnail_url,
main.ID
FROM wp_jlwx_posts AS main
INNER JOIN wp_jlwx_term_relationships AS parent ON main.ID = parent.object_id
INNER JOIN wp_jlwx_term_taxonomy AS parent_taxonomy ON parent.term_taxonomy_id = parent_taxonomy.term_taxonomy_id
INNER JOIN wp_jlwx_terms AS parent_data ON parent_taxonomy.term_id = parent_data.term_id
INNER JOIN wp_jlwx_term_taxonomy AS root_taxonomy ON parent_taxonomy.parent = root_taxonomy.term_taxonomy_id
INNER JOIN wp_jlwx_terms AS root_data ON root_taxonomy.term_taxonomy_id = root_data.term_id
LEFT JOIN wp_jlwx_postmeta AS linker ON main.ID = linker.post_id AND linker.meta_key = '_thumbnail_id'
LEFT JOIN wp_jlwx_postmeta AS thumbnail_data ON linker.meta_value = thumbnail_data.post_id
WHERE main.post_type = 'business'
AND main.post_status = 'publish'
$search_where_clause
$character_have_clause
ORDER BY root_title, parent_title, title

让我惊讶的第一件事是我在分类表上加入了两次。如何确保“主”表中的每一行只返回一行?

(编辑)我已经能够将范围缩小到缩略图连接,我在其中从元表接收额外的数据:例如a:5:{s:5:"宽度";i:960;s:6:"高度"...

最佳答案

我已经找到了问题:

Wordpress 在将缩略图添加到元表中时会存储元数据。

该位置使用meta_key:_wp_attached_file存储,而额外数据则使用meta_key:_wp_attachment_metadata存储。

因此,如果我将 meta_key = "_wp_attached_file"添加到最后一个连接,我的问题就解决了。

关于php - Wordpress 分类查询中的 double ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28970346/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com