WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp count attachments

Contents

Description

Count number of attachments for the mime type(s).

If you set the optional mime_type parameter, then an array will still be returned, but will only have the item you are looking for. It does not give you the number of attachments that are children of a post. You can get that by counting the number of children that post has.

Usage

<?php wp_count_attachments$mime_type ); ?>

Parameters

$mime_type
(string|array) (optional) Optional. Array or comma-separated list of MIME patterns.
Default:

Return Values

(array) 
Number of posts for each mime type.

Change Log

Since: 2.5

Source File

wp_count_attachments() is located in wp-includes/post.php