Filter hook 'pre_wp_list_authors_post_counts_query'

in WP Core File wp-includes/author-template.php at line 483

View Source

pre_wp_list_authors_post_counts_query

Filter Hook
Description
Filters whether to short-circuit performing the query for author post counts.

Hook Information

File Location wp-includes/author-template.php View on GitHub
Hook Type Filter
Line Number 483

Hook Parameters

Type Name Description
int[]|false $post_counts Array of post counts, keyed by author ID.
array $parsed_args The arguments passed to wp_list_authors() combined with the defaults.

Usage Examples

Basic Usage
<?php
// Hook into pre_wp_list_authors_post_counts_query
add_filter('pre_wp_list_authors_post_counts_query', 'my_custom_filter', 10, 2);

function my_custom_filter($post_counts, $parsed_args) {
    // Your custom filtering logic here
    return $post_counts;
}

Source Code Context

wp-includes/author-template.php:483 - How this hook is used in WordPress core
<?php
 478  	 * @since 6.1.0
 479  	 *
 480  	 * @param int[]|false $post_counts Array of post counts, keyed by author ID.
 481  	 * @param array       $parsed_args The arguments passed to wp_list_authors() combined with the defaults.
 482  	 */
 483  	$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args );
 484  
 485  	if ( ! is_array( $post_counts ) ) {
 486  		$post_counts       = array();
 487  		$post_counts_query = $wpdb->get_results(
 488  			"SELECT DISTINCT post_author, COUNT(ID) AS count

PHP Documentation

<?php
/**
	 * Filters whether to short-circuit performing the query for author post counts.
	 *
	 * @since 6.1.0
	 *
	 * @param int[]|false $post_counts Array of post counts, keyed by author ID.
	 * @param array       $parsed_args The arguments passed to wp_list_authors() combined with the defaults.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/author-template.php
Related Hooks

Related hooks will be displayed here in future updates.