Images are integral part of any website. Photo blogging now a days becoming more and more popular among event bloggers. New and lazy bloggers also do not want to write articles on every day but they want a constant money from their blog all the way. Right ?
Wallpaper Based weblog is such a web site and while working on our Abhishek Wallpaper Theme, We were forced to find out how many Wallpapers/ Photos, we have uploaded on our website.
To count total Image uploaded in WordPress, Just copy-paste the following code inside your functions.php file
/*---count total number of images in image gallery---*/
$query_img_args = array(
'post_type' => 'attachment',
'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 );
The above code will count total no. of image files available as an attachment. Now its time to use this function in your single.php file or any other file wherever you want to use.
Just copy-paste the following code to display total no. of uploaded Images.
Note: If you want to count any other type of uploaded file, Just change the post_mime_type and fire this query.
The Whole concept was developed by the man you are watching here. I am rakesh Kumar Serial Niche Blogger and SEO Enthusiast. find me onfacebookandon twitter.. Developed popular WordPress theme for Wallpapers and funny Image WordPress theme. Love SEO optimized WordPress theme Designing and Customization.