How to Show Total Number of Attachments in WordPress

Here’s another handy code snippet which allows you to display total number of attachments uploaded on your WordPress website or blog.

Quick Tip : Adding Class to WordPress Post Thumbnail

<?php 
$attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => -1 ) );
echo count($attachments); 
?>

 

0 Comments

Leave a Comment.