get_private_posts_cap_sql() WordPress Function

The get_private_posts_cap_sql() function is a helper function that retrieves the SQL code needed to create a private posts capability. This function is used internally by WordPress to create capabilities.

get_private_posts_cap_sql( string|array $post_type ) #

Retrieve the private post SQL based on capability.


Description

This function provides a standardized way to appropriately select on the post_status of a post type. The function will return a piece of SQL code that can be added to a WHERE clause; this SQL is constructed to allow all published posts, and all private posts to which the user has access.


Top ↑

Parameters

$post_type

(string|array)(Required)Single post type or an array of post types. Currently only supports 'post' or 'page'.


Top ↑

Return

(string) SQL code that can be added to a where clause.


Top ↑

Source

File: wp-includes/post.php

function get_private_posts_cap_sql( $post_type ) {
	return get_posts_by_author_sql( $post_type, false );
}


Top ↑

Changelog

Changelog
VersionDescription
4.3.0Added the ability to pass an array to $post_type.
2.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More