WP Tiny Statistics

tiny_statistics by Mr.CrazyappleThis is a small piece of code to create a tiny blog statistic.
Two queries counts all blog posts and pages and the second counts all used images.

The third query selects the last four entries from the wordpress posts table.

SQL Part:
Selects the last four modified entries (LIMIT 0, 4). If you want to see more post increase the last number.

require_once( ABSPATH . 'wp-includes/query.php');
global $wpdb;
$table__posts = $wpdb->prefix . "posts";

$hpe_count = $wpdb->get_var("SELECT count(*)FROM ".$table__posts." WHERE post_status ='publish' and (post_type ='post' OR post_type ='page') ");
$hpe_imgcount = $wpdb->get_var("SELECT count(*)FROM ".$table__posts." WHERE post_mime_type = 'image/png'");
$sql = "SELECT `ID`,`post_modified_gmt`,`post_title`,`post_status`,`guid`, `post_type`
FROM ".$table__posts."
WHERE post_status ='publish' and (post_type ='post' OR post_type ='page')
ORDER BY `post_modified` DESC LIMIT 0, 4";
$get_articles = $wpdb->get_results($sql, ARRAY_A);

HTML / PHP Part:

<b>Last update:</b>
<?php foreach ($get_articles as $hpe_current_article) { ?>
	<br><strong><?php echo $hpe_current_article['post_type']; ?></strong>:&nbsp;<a href="<?php echo $hpe_current_article['guid']; ?>" target="_self"><?php echo $hpe_current_article['post_title'];?></a> <em><?php echo substr($hpe_current_article['post_modified_gmt'],0,10); ?></em></a> 
<?php }?>
<br></hr>
<br> published articles/pages: <b>
<?php echo $hpe_count; ?> </b>
<br> embedded images: <b>
<?php echo $hpe_imgcount; ?> </b>