问题描述
query_posts 的 WordPress 代码页表示它不包括 query_posts 所采用的所有参数:
Parameters
This is not an exhaustive list yet. It is meant to show some of the more common things possible with setting your own queries
我找不到 query_posts 接受的所有参数的参考,尽管如此,即使在一个简单的列表形式。有没有这个数据可以使用的 cheat-sheet 或类似的东西?
最佳解决方案
以下是从/wp-includes/query.php (lines 1246-1550)的 parse_query()功能中找到的 WordPress 3.0.1 的一切。但是,插件可能添加参数,因此列表永远不能完全完成:
-
attachment -
attachment_id -
author -
author_name -
cat -
category__and -
category__in -
category__not_in -
category_name -
comments_popup -
day -
error -
feed -
hour -
m -
minute -
monthnum -
name -
order -
orderby -
p -
page_id -
page -
paged -
pagename -
post__in -
post__not_in -
post_status -
post_type -
preview -
robots -
s -
sentence -
second -
static -
subpost -
subpost_id -
tag__and -
tag__in -
tag__not_in -
tag_id -
tag_slug__and -
tag_slug__in -
tag -
taxonomy– (前 3.1) -
tb -
term– (前 3.1) -
w -
withcomments -
withoutcomments -
yearPre WP 3.1 -
meta_key -
meta_value自 WP 3.1 起 -
fields -
meta_query -
tax_query
次佳解决方案
如果您可以阅读 PHP 代码,可以查看文件 wp-includesquery.php 的 WP_Query 类中的函数 parse_query($query)
支持的参数都在此列出和管理。
参考文献
注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。