{"id":232945,"date":"2023-02-01T17:45:00","date_gmt":"2023-02-01T14:45:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232945"},"modified":"2022-11-10T18:27:54","modified_gmt":"2022-11-10T15:27:54","slug":"como-exibir-estatisticas-do-blog-no-rodape-da-pagina","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/pt-pt\/como-exibir-estatisticas-do-blog-no-rodape-da-pagina\/","title":{"rendered":"Como exibir estat\u00edsticas do blog no rodap\u00e9 da p\u00e1gina?"},"content":{"rendered":"<p>Quase todo tema wordpress tem um arquivo <strong>footer.php<\/strong> que cont\u00e9m o layout do rodap\u00e9 da p\u00e1gina. Voc\u00ea pode inserir o seguinte c\u00f3digo PHP+MySQL para exibir algumas estat\u00edsticas do blog no final de cada p\u00e1gina.<\/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>A data em que voc\u00ea publicou sua primeira postagem \u00e9 armazenada na vari\u00e1vel PHP <strong>$start<\/strong> e, portanto, modifique-a de acordo. O c\u00f3digo PHP acima executa tr\u00eas instru\u00e7\u00f5es SQL para tr\u00eas n\u00fameros: o n\u00famero de posts, o n\u00famero de p\u00e1ginas e o n\u00famero de coment\u00e1rios. A diferen\u00e7a de dia \u00e9 calculada.<\/p>\n<p>Observe tamb\u00e9m que, se voc\u00ea tiver um plug-in de cache do seu blog wordpress, exibir informa\u00e7\u00f5es atualizadas diariamente pode for\u00e7ar seu cache a ser invalidado uma vez por dia.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte de grava\u00e7\u00e3o:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Como exibir estat\u00edsticas do blog no rodap\u00e9 da p\u00e1gina?<\/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":[898,806,816,846,867],"tags":[1170],"class_list":["post-232945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codigo-2","category-php-8","category-plug-ins","category-tutoriais","category-wordpress-8","tag-affiai-pt-pt"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts\/232945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/comments?post=232945"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts\/232945\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/media\/223984"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/media?parent=232945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/categories?post=232945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/tags?post=232945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}