{"id":232990,"date":"2023-02-01T17:12:00","date_gmt":"2023-02-01T14:12:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232990"},"modified":"2022-11-10T18:39:37","modified_gmt":"2022-11-10T15:39:37","slug":"comment-afficher-les-statistiques-du-blog-en-pied-de-page","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/fr\/comment-afficher-les-statistiques-du-blog-en-pied-de-page\/","title":{"rendered":"Comment afficher les statistiques du blog en pied de page\u00a0?"},"content":{"rendered":"<p>Presque tous les th\u00e8mes wordpress ont un fichier <strong>footer.php<\/strong> qui contient la mise en page du pied de page. Vous pouvez ins\u00e9rer le code PHP+MySQL suivant pour afficher quelques statistiques du blog \u00e0 la fin de chaque page.<\/p>\n<pre><code>&lt;?php\nglobal $wpdb;\/\/ &lt;a class=\"vglnk\" target=\"_blank\" href=\"https:\/\/helloacm.com\" rel=\"nofollow\"&gt;&lt;span&gt;https&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;helloacm&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\n$query = \"select count(1) from `wp_posts` where `post_status`='publish' and `post_type`='post'\";\n$cnt_posts = $wpdb-&gt;get_var($query);\n$query = \"select count(1) from `wp_posts` where `post_status`='publish' and `post_type`='page'\";\n$cnt_pages = $wpdb-&gt;get_var($query);\n$query = \"select count(1) from `wp_comments` where `comment_approved`=1\";\n$cnt_comments = $wpdb-&gt;get_var($query);\n$start = strtotime(\"2011-07-03 00:00:00\"); \u00a0\/\/ Need to replace the date to the date when you published your first article.\n$today = strtotime(date(\"Y-m-d h:i:s\"));\n$days = round(abs($today - $start) \/ 3600 \/ 24);\n?&gt;\n\u00a0\nBlog is up for &lt;?php echo $days;?&gt; days, and there are &lt;?php echo $cnt_posts;?&gt; posts and &lt;?php echo $cnt_pages;?&gt; pages, there are &lt;?php echo $cnt_comments;?&gt; comments.<\/code><\/pre>\n<p>La date \u00e0 laquelle vous avez publi\u00e9 votre premier message est stock\u00e9e dans la variable PHP <strong>$start<\/strong> et, par cons\u00e9quent, veuillez la modifier en cons\u00e9quence. Le code PHP ci-dessus ex\u00e9cute trois instructions SQL pour trois nombres\u00a0: le nombre de publications, le nombre de pages et le nombre de commentaires. La diff\u00e9rence de jour est calcul\u00e9e.<\/p>\n<p>Veuillez \u00e9galement noter que si vous avez un plugin de cache de votre blog wordpress, l&rsquo;affichage d&rsquo;informations mises \u00e0 jour quotidiennement peut forcer votre cache \u00e0 \u00eatre invalid\u00e9 une fois par jour.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Source d&rsquo;enregistrement:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comment afficher les statistiques du blog en pied de page\u00a0?<\/p>\n","protected":false},"author":1,"featured_media":223984,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[893,801,811,841,862],"tags":[1167],"class_list":["post-232990","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-2","category-php-3","category-plugins-2","category-tutoriels","category-wordpress-3","tag-affiai-fr"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/posts\/232990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/comments?post=232990"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/posts\/232990\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/media\/223984"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/media?parent=232990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/categories?post=232990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fr\/wp-json\/wp\/v2\/tags?post=232990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}