I've got a custom image gallery in WordPress installed and i want to display in one of the footer boxs how many their are? I've tried lots but this is the only code actually showing a result but its wrong!
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts);
echo 'We have published '.$numposts.' since our launch.';
?>