get_query_var()
get_query_var( string $var, mixed $default = ” )
在WP_Query类中检索变量。
Retrieve variable in the WP_Query class.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$var | (string) | 必需 | 要检索的变量键。 |
$default | (mixed) | 可选 | 如果未设置查询变量,则返回的值。 |
返回(Return)
(mixed)查询变量的内容。
源码(Source)
/** * Retrieve variable in the WP_Query class. * * @since 1.5.0 * * @global WP_Query $wp_query * * @param string $var The variable key to retrieve. * @param mixed $default Value to return if the query variable is not set. Default ''. * @return mixed */ function get_query_var( $var, $default = '' ) { global $wp_query; return $wp_query->get( $var, $default ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
3.9.0 | wp-includes/query.php:26 | 31 | 1 function |
笔记(Notes)
获取当前页码
get_query_var() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_query_var/