WordPressでは、?p=123
のような形でブラウザからのリクエストパラメータ(クエリストリング)を受け付けることができます。
標準インストールされたWordPressが処理できるパラメータの一覧は下記のとおりです。
m
p
posts
w
cat
withcomments
withoutcomments
s
search
exact
sentence
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
attachment
attachment_id
subpost
subpost_id
preview
robots
taxonomy
term
cpage
post_type
embed
この一覧は、wp-includes\class-wp.php上で指定されています。
プラグインを作る時などで、受け入れ可能なパラメータを追加したい場合は、query_varsフィルタで増やすことができます。
下記の例では、custom_keyパラメータを追加しています。
add_filter('query_vars'、function ( $keys ) {
$keys[] = "custom_key";
return $key;
});
関連記事
コメントを残す