Alert: 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.

_count_posts_cache_key() WordPress Function

The _count_posts_cache_key() function is used to generate a unique cache key for storing the number of posts for a given query. This function is used internally by the Wordpress function count_posts().

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

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


Parameters

$type

(string)(Optional) Post type to retrieve count

Default value: 'post'

$perm

(string)(Optional) 'readable' or empty.

Default value: ''


Top ↑

Return

(string) The cache key.


Top ↑

Source

File: wp-includes/post.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
3.9.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