wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



pre_wp_count_attachments › WordPress Filter Hooks

Seit7.2.0
Veraltetn/v
› apply_filters( 'pre_wp_count_attachments', null, $mime_type )
Parameter: (2)
  • () counts An object containing the attachment counts by mime type, or null to run the default query. Default null.
    Erforderlich: Ja
  • () mime_type Array or comma-separated list of MIME patterns.
    Erforderlich: Ja
Definiert in:
Codex:

Filters the attachment counts before the query is run.

Returning a stdClass object short-circuits wp_count_attachments(), skipping both the object cache lookup and the database queries. This allows the counts to be served from another source, such as a value pre-computed in the background, when an exact real-time count is not required. If the filtered value does not contain a trash count, one is added to the result and set to zero. Missing MIME types are not added, as they depend on the attachments that exist. The filtered value should therefore contain a count for every MIME type matching `$mime_type` that has attachments, including types first uploaded after the value was computed, as callers may read the count for any MIME type that exists. It should also contain only MIME types matching `$mime_type`, with a trash count limited to attachments of those types, as the default query does. The returned value is not cached and passed through the {@see 'wp_count_attachments'} filter.




Quellcode

$counts = apply_filters( 'pre_wp_count_attachments', null, $mime_type );