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

返回介绍

is_post_type_viewable()

发布于 2017-09-11 字数2395 浏览 874 评论 0

is_post_type_viewable( string|WP_Post_Type $post_type )

Determines whether a post type is considered “viewable”.


描述

For built-in post types such as posts and pages, the ‘public’ value will be evaluated. For all others, the ‘publicly_queryable’ value will be used.


参数

$post_type

(string|WP_Post_Type)
(Required)
Post type name or object.


返回值

(bool) Whether the post type should be considered viewable.


源代码

File: wp-includes/post.php

function is_post_type_viewable( $post_type ) {
	if ( is_scalar( $post_type ) ) {
		$post_type = get_post_type_object( $post_type );
		if ( ! $post_type ) {
			return false;
		}
	}

	return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
}

更新日志

Version 描述
4.6.0 Converted the $post_type parameter to accept a WP_Post_Type object.
4.5.0 Added the ability to pass a post type name in addition to object.
4.4.0 Introduced.

相关函数

Uses

  • wp-includes/post.php:
    get_post_type_object()

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:
    WP_REST_Posts_Controller::get_item()
  • wp-includes/class-wp-post-type.php:
    WP_Post_Type::add_rewrite_rules()
  • wp-includes/link-template.php:
    get_preview_post_link()
  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::handle_row_actions()
  • wp-admin/includes/meta-boxes.php:
    post_submit_meta_box()
  • wp-includes/general-template.php:
    wp_get_archives()
  • wp-includes/class-wp.php:
    WP::parse_request()
  • Show 2 more used by
    Hide more used by


User Contributed Notes

上一篇:is_post_type_hierarchical()

下一篇:is_preview()

发布评论

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

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