Retrieves all of the taxonomies that are registered for attachments.
Description
Handles mime-type-specific taxonomies such as attachment:image and attachment:video.
See also
Parameters
$output
stringoptional- The type of taxonomy output to return. Accepts
'names'
or'objects'
.
Default'names'
.Default:
'names'
Source
/**
* Retrieves taxonomies attached to given the attachment.
*
* @since 2.5.0
* @since 4.7.0 Introduced the `$output` parameter.
*
* @param int|array|object $attachment Attachment ID, data array, or data object.
* @param string $output Output type. 'names' to return an array of taxonomy names,
* or 'objects' to return an array of taxonomy objects.
* Default is 'names'.
* @return string[]|WP_Taxonomy[] List of taxonomies or taxonomy names. Empty array on failure.
*/
function get_attachment_taxonomies( $attachment, $output = 'names' ) {
if ( is_int( $attachment ) ) {
$attachment = get_post( $attachment );
} elseif ( is_array( $attachment ) ) {
$attachment = (object) $attachment;
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.