{"id":99928,"date":"2013-03-18T19:10:13","date_gmt":"2013-03-18T19:10:13","guid":{"rendered":""},"modified":"2016-07-30T23:47:25","modified_gmt":"2016-07-30T23:47:25","slug":"%d0%bd%d0%b5-%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d0%bb%d1%8c%d0%bd%d0%be-%d1%81%d1%87%d0%b8%d1%82%d0%b0%d0%b5%d1%82-%d1%81%d1%87%d0%b5%d1%82%d1%87%d0%b8%d0%ba-%d0%ba%d0%be%d0%bb%d0%b8%d1%87%d0%b5%d1%81","status":"closed","type":"topic","link":"https:\/\/ru.wordpress.org\/support\/topic\/%d0%bd%d0%b5-%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d0%bb%d1%8c%d0%bd%d0%be-%d1%81%d1%87%d0%b8%d1%82%d0%b0%d0%b5%d1%82-%d1%81%d1%87%d0%b5%d1%82%d1%87%d0%b8%d0%ba-%d0%ba%d0%be%d0%bb%d0%b8%d1%87%d0%b5%d1%81\/","title":{"rendered":"\u041d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0437\u0430"},"content":{"rendered":"<p>\u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0445\u0430\u043a). \u0412 \u044d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a &lt;?php setPostViews(get_the_ID()); ?&gt; , \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 single.php.<br \/>\n\u0412\u043e\u0442 \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442<br \/>\n\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0432 functions.php<\/p>\n<pre><code>function getPostViews($postID){\n$count_key = &#039;post_views_count&#039;;\n$count = get_post_meta($postID, $count_key, true);\nif($count==&#039;&#039;){\ndelete_post_meta($postID, $count_key);\nadd_post_meta($postID, $count_key, &#039;0&#039;);\nreturn &quot;0 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432&quot;;\n}\nreturn &#039;\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432: &#039;.$count;\n}\nfunction setPostViews($postID) {\n$count_key = &#039;post_views_count&#039;;\n$count = get_post_meta($postID, $count_key, true);\nif($count==&#039;&#039;){\n$count = 0;\ndelete_post_meta($postID, $count_key);\nadd_post_meta($postID, $count_key, &#039;0&#039;);\n}else{\n$count++;\nupdate_post_meta($postID, $count_key, $count);\n}\n}<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432, \u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 &lt;?php echo get_post_meta($post-&gt;ID, &#8216;post_views_count&#8217;, true); ?&gt; \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u0432 \u0446\u0438\u0444\u0440\u0430\u0445), \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (\u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, &#8212; \u043d\u0430 \u0413\u043b\u0430\u0432\u043d\u043e\u0439).<\/p>\n<p>\u041f\u0420\u041e\u0411\u041b\u0415\u041c\u0410 (\u0441\u0431\u043e\u0439, \u043d\u0435\u043f\u043e\u043b\u0430\u0434\u043a\u0430): \u041f\u0440\u0438 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432, \u0432\u043c\u0435\u0441\u0442\u043e +1, \u0434\u0435\u043b\u0430\u0435\u0442 +2. \u0422.\u0435. \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e 0 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 &#8212; \u0437\u0430\u0448\u0435\u043b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e +2 &#8212; \u0435\u0449\u0435 \u0440\u0430\u0437 \u043e\u0431\u043d\u043e\u0432\u0438\u043b, \u043e\u043f\u044f\u0442\u044c +2 (\u0443\u0436\u0435 4) \u043d\u0443 \u0438 \u0442.\u0434.<br \/>\n\u041f\u043e\u0434\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d.<\/p>\n","protected":false},"template":"","class_list":["post-99928","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/99928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/99928\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=99928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}