{"id":232944,"date":"2023-02-01T17:34:00","date_gmt":"2023-02-01T14:34:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232944"},"modified":"2022-11-10T18:27:42","modified_gmt":"2022-11-10T15:27:42","slug":"kuinka-naeyttaeae-blogitilastot-sivun-alatunnisteessa","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/fi\/kuinka-naeyttaeae-blogitilastot-sivun-alatunnisteessa\/","title":{"rendered":"Kuinka n\u00e4ytt\u00e4\u00e4 blogitilastot sivun alatunnisteessa?"},"content":{"rendered":"<p>L\u00e4hes jokaisessa wordpress-teemassa on <strong>footer.php-<\/strong> tiedosto, joka sis\u00e4lt\u00e4\u00e4 sivun alatunnisteen asettelun. Voit lis\u00e4t\u00e4 seuraavan PHP+MySQL-koodin n\u00e4ytt\u00e4\u00e4ksesi joitain blogin tilastoja jokaisen sivun lopussa.<\/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>P\u00e4iv\u00e4m\u00e4\u00e4r\u00e4, jolloin julkaisit ensimm\u00e4isen viestisi, on tallennettu PHP-muuttujaan <strong>$start<\/strong>, joten muuta sit\u00e4 vastaavasti. Yll\u00e4 oleva PHP-koodi suorittaa kolme SQL-lausetta kolmelle numerolle: viestien m\u00e4\u00e4r\u00e4, sivujen m\u00e4\u00e4r\u00e4 ja kommenttien m\u00e4\u00e4r\u00e4. P\u00e4iv\u00e4n ero lasketaan.<\/p>\n<p>Huomaa my\u00f6s, ett\u00e4 jos sinulla on v\u00e4limuistilaajennus wordpress-blogissasi, p\u00e4ivitt\u00e4in p\u00e4ivitett\u00e4vien tietojen n\u00e4ytt\u00e4minen voi pakottaa v\u00e4limuistisi mit\u00e4t\u00f6im\u00e4\u00e4n kerran p\u00e4iv\u00e4ss\u00e4.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kuinka n\u00e4ytt\u00e4\u00e4 blogitilastot sivun alatunnisteessa?<\/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":[895,813,843,803,864],"tags":[1166],"class_list":["post-232944","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-koodi","category-laajennuksia","category-opetusohjelmia","category-php-5","category-wordpress-5","tag-affiai-fi"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts\/232944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/comments?post=232944"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/posts\/232944\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/media\/223984"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/media?parent=232944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/categories?post=232944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/fi\/wp-json\/wp\/v2\/tags?post=232944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}