WordPress.org

Ready to get started?Download WordPress

Forums

Number of uploads/pictures (1 post)

  1. leisegang
    Member
    Posted 5 years ago #

    <?php
    /*
    Plugin Name: Sitewide Picture Count
    Plugin URI: http://www.udyr.com
    Description: Counts number of uploads. use:   <b> sitewide_picture_count(); </b>   inside of php tags
    Author: Patrick
    Version: 0.1
    Author URI: http://www.udyr.com
    
    */
    
    function sitewide_picture_count_query() {
      global $wpdb, $blog_id, $pictures;
    
    	$and = wp_post_mime_type_where( $mime_type );
    	$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' $and GROUP BY post_mime_type", ARRAY_A );
    
    	$pictures = array( );
    	foreach( (array) $count as $row ) {
    		$pictures[$row['post_mime_type']] = $row['num_posts'];
    	}
    
    	return $pictures;
    }
    function sitewide_picture_count() {
    	$pictures = sitewide_picture_count_query();
    echo '';
    
    	var_dump($pictures);
    }
    ?>

    How do i get this number outputted in 1 numer and not by type?
    Like "You have a total of ## uploads!"

Topic Closed

This topic has been closed to new replies.

About this Topic