{"id":10385,"date":"2016-09-08T00:48:40","date_gmt":"2016-09-07T21:48:40","guid":{"rendered":"https:\/\/www.coma.lv\/?p=10385"},"modified":"2016-09-14T19:15:34","modified_gmt":"2016-09-14T16:15:34","slug":"kak-perenapravit-polzovatelej-na-sluchajnyj-post-v-wordpress","status":"publish","type":"post","link":"https:\/\/coma.lv\/ru\/2016\/09\/08\/kak-perenapravit-polzovatelej-na-sluchajnyj-post-v-wordpress\/","title":{"rendered":"\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u0432 WordPress"},"content":{"rendered":"<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0430\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043d\u043e\u043f\u043e\u043a, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u0451, \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u041c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u043a\u0430\u043a \u0432 \u0433\u0443\u0433\u043b\u0435 &#8220;\u041c\u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u0451\u0442&#8221;. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u0432\u0430\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u0432 WordPress.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0442\u0435\u043c\u044b\u00a0functions.php \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nadd_action('init','random_add_rewrite');\r\nfunction random_add_rewrite() {\r\n       global $wp;\r\n       $wp-&gt;add_query_var('random');\r\n       add_rewrite_rule('random\/?$', 'index.php?random=1', 'top');\r\n}\r\n\r\nadd_action('template_redirect','random_template');\r\nfunction random_template() {\r\n       if (get_query_var('random') == 1) {\r\n               $posts = get_posts('post_type=post&amp;orderby=rand&amp;numberposts=1');\r\n               foreach($posts as $post) {\r\n                       $link = get_permalink($post);\r\n               }\r\n               wp_redirect($link,307);\r\n               exit;\r\n       }\r\n}\r\n<\/pre>\n<p><strong>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043f\u043f\u0435\u0442\u0430:<\/strong><\/p>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043d\u0438\u043f\u043f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e Random. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u00a0<em>template_redirect<\/em>\u00a0\u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442: \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f random \u0437\u0434\u0435\u0441\u0442\u044c, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u043d\u0438\u043f\u043f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 307 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 &#8211; \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0427\u0430\u0441\u0442\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442 302 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0441\u0432\u043e\u0438\u043c\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h4>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0431\u0430\u0433\u043e\u0432:<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 W3 Total Cache \u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0449\u0430\u044f\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0432\u0430\u043c \u00a0\u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a \u043b\u0438\u0441\u0442\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439:<\/p>\n<p>\/random\/<br \/>\n\/index.php?random=1<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Yoast SEO \u043f\u043b\u0430\u0433\u0438\u043d, \u0442\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u043b\u0430\u0436\u043e\u043a \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043b\u043e\u0445\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a, \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<hr \/>\n<p><em>\u041d\u0430\u0448\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8211; \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u0430\u0439\u0442\u043e\u0432 \u043d\u0430 WordPress. \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u0434\u043b\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0438 &#8211; <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0430\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043d\u043e\u043f\u043e\u043a, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u0451, \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u041c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u043a\u0430\u043a \u0432 \u0433\u0443\u0433\u043b\u0435 &#8220;\u041c\u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u0451\u0442&#8221;. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u0432\u0430\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u0432 WordPress. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0442\u0435\u043c\u044b\u00a0functions.php \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10490,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[573,623],"tags":[],"class_list":["post-10385","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorialy"],"_links":{"self":[{"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/posts\/10385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/comments?post=10385"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/posts\/10385\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/media\/10490"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/media?parent=10385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/categories?post=10385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/ru\/wp-json\/wp\/v2\/tags?post=10385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}