wordpress的文章查询类WP_Query

new WP_Query(string|array $query)

$query

七十多个参数

参数说明类型可选值默认值
attachment_idsmintselectdefault
authorsmint | stringselectdefault
author_namesmstringselectdefault
author__insmarrayselectdefault
author__not_insmarrayselectdefault
cache_resultssmboolselectdefault
catsmint | stringselectdefault
category__and分类的IDarrayselectdefault
category__insmarrayselectdefault
category__not_insmarrayselectdefault
category_namesmstringselectdefault
comment_countsmarray | intselectdefault
comment_statussmstringselectdefault
comments_per_pagesmintselectdefault
date_querysmarrayselectdefault
daysmintselectdefault
exactsmboolselectdefault
fieldssmstringselectdefault
hoursmintselectdefault
ignore_sticky_posts是否忽略粘性帖子。int | booldefault
msmintselectdefault
meta_comparesmstringselectdefault
meta_compare_keysmstringselectdefault
meta_keysmstringselectdefault
meta_querysmarrayselectdefault
meta_valuesmstringselectdefault
meta_value_numsmintselectdefault
meta_type_keysmstringselectdefault
menu_ordersmintselectdefault
monthnumsmintselectdefault
namesmstringselectdefault
nopagingsmboolselectdefault
no_found_rowssmboolselectdefault
offsetsmintselectdefault
ordersmstringselectdefault
orderbysmstring | arrayselectdefault
psmintselectdefault
pagesmintselectdefault
pagedsmintselectdefault
page_idsmintselectdefault
pagenamesmstringselectdefault
permsmstringselectdefault
ping_statussmstringselectdefault
post__in文章的idarray
post__not_insmarrayselectdefault
post_mime_typesmstringselectdefault
post_name__insmarrayselectdefault
post_parentsmintselectdefault
post_parent__insmarrayselectdefault
post_parent__not_insmarrayselectdefault
post_typesmstring | arrayselectdefault
post_statussmstring | arrayselectdefault
posts_per_page要查询的文章数数量。使用-1获取所有文章intdefault
posts_per_archive_pagesmintselectdefault
ssmstringselectdefault
secondsmintselectdefault
sentencesmboolselectdefault
suppress_filterssmboolselectdefault
tagsmstringselectdefault
tag__andsmarrayselectdefault
tag__insmarrayselectdefault
tag__not_insmarrayselectdefault
tag_idsmintselectdefault
tag_slug__andsmarrayselectdefault
tag_slug__insmarrayselectdefault
tax_querysmarrayselectdefault
titlesmstringselectdefault
update_post_meta_cachesmboolselectdefault
update_post_term_cachesmboolselectdefault
lazy_load_term_metasmboolselectdefault
wsmintselectdefault
yearsmintselectdefault

之前有一个showposts参数,不过自2.1版开始就被替换成了posts_per_page。

评论
:broken_heart: :confounded: :flushed: :frowning: :grinning: :heart: :kissing_heart: :mask: :pensive: :rage: :relaxed: :scream: :smile: :smirk: :sob: :stuck_out_tongue_closed_eyes: :stuck_out_tongue_winking_eye: :wink: