当サイト、Codex 日本語版は今後積極的な更新は行わない予定です。後継となる新ユーザーマニュアルは、https://ja.wordpress.org/support/ にあります。
万が一、当サイトで重大な問題を発見した際などは、フォーラムWordSlack #docs チャンネルでお知らせください。</p>

WordPress Query Vars

提供: WordPress Codex 日本語版
2014年4月19日 (土) 16:11時点におけるNao (トーク | 投稿記録)による版 (2014-01-08T04:19:39 Eek 版から新規作成。)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Query Vars

An array of query vars are available for WordPress users or developers to utilise in order to query for particular types of content or to aid in theme and/or plugin design and functionality.

Public query vars are those available and usable via a direct URL query in the form of.

example.net/?var1=value1&var2=value2

Private query vars cannot be used in the URL, although WordPress will accept a query string with private query vars, the values will not be passed into the query and should be placed directly into the query. An example is given below.

query_posts('privatevar=myvalue');
Note: Query vars are not necessarily the same thing as query args in URLs (e.g., add_query_arg( 'foo' ). Query vars should only be registered for parameters that actually affect the behavior of WP_Query, and not just for any value passed in the URL. See #16373 for details.

Query Examples

Custom post types and taxonomies can also be queried publicly.

Query Post Type

example.net/?post_type=value1

In this example, value1 would be the post type slug you want to query. This would return all posts that match the specified post_type slug.

Query Custom Taxonomy

example.net/?tax1=term1

In this example, tax1 is the taxonomy slug and term1 is the term within that taxonomy that you would like to look up. This would return all posts (regardless of post_type) matching that taxonomy term.

Queries combining multiple values can be combined to form more complex, granular queries. For instance, to find only posts of a given post type AND taxonomy term, you can specify both.

Query variables

Public 
  • attachment
  • attachment_id
  • author
  • author_name
  • cat
  • category_name
  • comments_popup
  • day
  • error
  • feed
  • hour
  • hour
  • m
  • minute
  • monthnum
  • name
  • p
  • page_id
  • paged
  • pagename
  • post_parent
  • post_type
  • preview
  • second
  • static
  • subpost
  • subpost_id
  • tag
  • tag_id
  • tb
  • w
  • year
Private 
  • category__in
  • category__not_in
  • category__and
  • post__in
  • post__not_in
  • tag__in
  • tag__not_in
  • meta_key
  • meta_value


See this list:

$public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');

$private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page');


via http://www.cleancode.co.nz/blog/731/post-data-wordpress-permalink-404

This list needs more work, if you have something to add go ahead.

このページ「WordPress Query Vars」はまだ書きかけで、情報が不足しています。続きを書いて WordPress を手助けしましょう.


このページはラフドラフトで、まだ内容の検証が済んでいません。情報が間違っていたり書き直されることがあります。
執筆中のため、執筆者の許可なく編集しないでください

最新英語版: WordPress Codex » WordPress_Query_Vars最新版との差分