問題描述

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

  • year Pre WP 3.1

  • meta_key

  • meta_value 自 WP 3.1 起

  • fields

  • meta_query

  • tax_query

次佳解決方案

如果您可以閲讀 PHP 代碼,可以查看文件 wp-includesquery.phpWP_Query 類中的函數 parse_query($query)

支持的參數都在此列出和管理。

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。