wordpress / latest / functions / _count_posts_cache_key.html

_count_posts_cache_key( string $type = 'post', string $perm = '' ): string

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Returns the cache key for wp_count_posts() based on the passed arguments.

Parameters

$type string Optional
Post type to retrieve count Default 'post'.

Default: 'post'

$perm string Optional
'readable' or empty.

Default: ''

Return

string The cache key.

Source

File: wp-includes/post.php. View all references

function _count_posts_cache_key( $type = 'post', $perm = '' ) {
	$cache_key = 'posts-' . $type;

	if ( 'readable' === $perm && is_user_logged_in() ) {
		$post_type_object = get_post_type_object( $type );

		if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
			$cache_key .= '_' . $perm . '_' . get_current_user_id();
		}
	}

	return $cache_key;
}

Used By

Used By Description

Changelog

Version Description
3.9.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_count_posts_cache_key