^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_query_var()用法示例

get_query_var( string $var,  mixed $default = '' )

Retrieve variable in the WP_Query class.


描述


参数

$var

(string)
(Required)
The variable key to retrieve.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

$default

(mixed)
(Optional)
Value to return if the query variable is not set.

Default value: ''


返回值

(mixed) Contents of the query variable.


源代码

File: wp-includes/query.php

function get_query_var( $var, $default = '' ) {
	global $wp_query;
	return $wp_query->get( $var, $default );
}

更新日志

Version 描述
3.9.0 The $default argument was introduced.
1.5.0 Introduced.

相关函数

Uses

  • wp-includes/class-wp-query.php:
    WP_Query::get()

Used By

  • wp-includes/link-template.php:
    wp_get_canonical_url()
  • wp-includes/category-template.php:
    wp_dropdown_categories()
  • wp-includes/general-template.php:
    paginate_links()
  • wp-includes/general-template.php:
    feed_links_extra()
  • wp-includes/general-template.php:
    get_search_query()
  • wp-includes/general-template.php:
    single_month_title()
  • wp-includes/general-template.php:
    wp_title()
  • wp-includes/general-template.php:
    post_type_archive_title()
  • wp-includes/class-wp.php:
    WP::handle_404()
  • wp-includes/query.php:
    wp_old_slug_redirect()
  • wp-includes/functions.php:
    do_feed()
  • wp-includes/link-template.php:
    get_next_comments_link()
  • wp-includes/link-template.php:
    get_previous_comments_link()
  • wp-includes/link-template.php:
    paginate_comments_links()
  • wp-includes/link-template.php:
    get_posts_nav_link()
  • wp-includes/user.php:
    wp_dropdown_users()
  • wp-includes/template.php:
    get_archive_template()
  • wp-includes/template.php:
    get_post_type_archive_template()
  • wp-includes/template.php:
    get_page_template()
  • wp-includes/post-template.php:
    get_body_class()
  • wp-includes/canonical.php:
    redirect_canonical()
  • wp-includes/canonical.php:
    redirect_guess_404_permalink()
  • wp-includes/comment-template.php:
    wp_list_comments()
  • wp-includes/comment-template.php:
    comments_template()
  • wp-includes/comment-template.php:
    get_comment_link()
  • wp-includes/comment.php:
    get_comment_pages_count()
  • wp-includes/comment.php:
    get_page_of_comment()
  • Show 22 more used by
    Hide more used by


  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Getting Current Pagination Number

    
    <?php $paged = get_query_var( 'paged', 1 ); ?>
    
    <h1><?php printf( esc_html__( 'Currently browsing page %s', 'textdomain' ), $paged ); ?></h1>
    

    For getting the current pagination number on a static front page (Page template) you have to use the page query variable:

    
    <?php  $page = get_query_var( 'page', 1 );  ?>
    <h1><?php printf( esc_html__( 'Currently browsing page %s on a static front page', 'textdomain' ), $page ); ?></h1>
    

    Note: The query variable page holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈