is_preview() - WordPress 函数参考中文文档

返回介绍

is_preview()

发布于 2017-09-11 字数1764 浏览 782 评论 0

is_preview()

Is the query for a post or page preview?


描述


返回值

(bool)


源代码

File: wp-includes/query.php

function is_preview() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;
	}

	return $wp_query->is_preview();
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    __()
  • wp-includes/class-wp-query.php:
    WP_Query::is_preview()
  • wp-includes/functions.php:
    _doing_it_wrong()

Used By

  • wp-includes/functions.php:
    wp_post_preview_js()
  • wp-includes/post-template.php:
    _wp_link_page()
  • wp-includes/canonical.php:
    redirect_canonical()

User Contributed Notes

  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

    Example

    
    if ( ! is_preview() ) {
        // Include analytics code
    }
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!