
利用Query Monitor插件调试WordPress并提高网站性能
is_post_publicly_viewable ( $post = null )
is_post_publicly_viewable: 这个函数检查一个文章是否可以公开查看。它以文章对象或ID为参数,如果文章可以公开查看,则返回true,如果不可以则返回false。
确定一个文章是否可以公开查看。
如果文章的状态和文章的类型都是可查看的,那么文章就被认为是可公开查看的。
function is_post_publicly_viewable( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } $post_type = get_post_type( $post ); $post_status = get_post_status( $post ); return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status ); }