Created
February 8, 2013 01:09
-
-
Save INDIAN2020/4735745 to your computer and use it in GitHub Desktop.
number of file in media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Count total number of jpg, gif, png images in media library | |
Adding the first snippet to the functions.php of your wordpress theme will display a count of all images within the media library. Add the second snippet in the location you wish to display the count total. | |
use this : <?php img_count(); ?> | |
*/ | |
function img_count(){ | |
$query_img_args = array( | |
'post_type' => 'attachment', | |
'post_mime_type' =>array( | |
'jpg|jpeg|jpe' => 'image/jpeg', | |
'gif' => 'image/gif', | |
'png' => 'image/png', | |
), | |
'post_status' => 'inherit', | |
'posts_per_page' => -1, | |
); | |
$query_img = new WP_Query( $query_img_args ); | |
echo $query_img->post_count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment