Quasi tutti i temi wordpress hanno un file footer.php che contiene il layout per il footer della pagina. Puoi inserire il seguente codice PHP+MySQL per visualizzare alcune statistiche del blog alla fine di ogni pagina.
<?php
global $wpdb;// <a class="vglnk" target="_blank" href="https://helloacm.com" rel="nofollow"><span>https</span><span>://</span><span>helloacm</span><span>.</span><span>com</span></a>
$query = "select count(1) from `wp_posts` where `post_status`='publish' and `post_type`='post'";
$cnt_posts = $wpdb->get_var($query);
$query = "select count(1) from `wp_posts` where `post_status`='publish' and `post_type`='page'";
$cnt_pages = $wpdb->get_var($query);
$query = "select count(1) from `wp_comments` where `comment_approved`=1";
$cnt_comments = $wpdb->get_var($query);
$start = strtotime("2011-07-03 00:00:00"); // Need to replace the date to the date when you published your first article.
$today = strtotime(date("Y-m-d h:i:s"));
$days = round(abs($today - $start) / 3600 / 24);
?>
Blog is up for <?php echo $days;?> days, and there are <?php echo $cnt_posts;?> posts and <?php echo $cnt_pages;?> pages, there are <?php echo $cnt_comments;?> comments.
La data in cui hai pubblicato il tuo primo post è memorizzata nella variabile PHP $start e, pertanto, ti preghiamo di modificarla di conseguenza. Il codice PHP di cui sopra esegue tre istruzioni SQL per tre numeri: il numero di post, il numero di pagine e il numero di commenti. Viene calcolata la differenza di giorno.
Tieni inoltre presente che se hai un plug-in per la cache del tuo blog wordpress, la visualizzazione di informazioni aggiornate quotidianamente potrebbe forzare l’annullamento della cache una volta al giorno.