View Single Post
Old 03-28-2015, 06:33 AM  
Kafka
Confirmed User
 
Kafka's Avatar
 
Join Date: Oct 2002
Location: Holland
Posts: 466
Quote:
Originally Posted by HowlingWulf View Post
Now sure how TGPX works with images, but if they're attached to the posts you can use this function in your theme:

Code:
function total_images() {
        global $wpdb;
        $images=  $wpdb->get_var("
                SELECT COUNT(ID) FROM $wpdb->posts
                WHERE (post_mime_type LIKE 'image/%')
                AND post_type = 'attachment'
                AND (post_status = 'inherit')
                AND post_parent > 0
        ");
        echo 'total attached images= '. $images;
}
In order to display total images just do this:
copy the function into the page where to display.
then "total_images();" this will invoke the function and echo the total images, if the query is correct ofcourse.

Dont use bash scripts for this.
Kafka is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote