{"id":233264,"date":"2023-02-10T16:49:00","date_gmt":"2023-02-10T13:49:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233264"},"modified":"2022-11-10T20:11:31","modified_gmt":"2022-11-10T17:11:31","slug":"dodajte-nastupnu-dovilnu-publikaciju-v-shablon-storinki-wordpress-za-dopomogoju-sql","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/dodajte-nastupnu-dovilnu-publikaciju-v-shablon-storinki-wordpress-za-dopomogoju-sql\/","title":{"rendered":"\u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0443 \u0434\u043e\u0432\u0456\u043b\u044c\u043d\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438 WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e SQL"},"content":{"rendered":"\n<p>\u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0447\u0430\u0441\u0442\u043e \u043e\u0442\u0440\u0438\u043c\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0440\u0430\u0434\u0438 \u0449\u043e\u0434\u043e \u043f\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044f SEO (\u043e\u043f\u0442\u0438\u043c\u0456\u0437\u0430\u0446\u0456\u0457 \u043f\u043e\u0448\u0443\u043a\u043e\u0432\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c), \u0434\u043e\u0434\u0430\u044e\u0447\u0438 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u0432\u0430\u0448\u0456 \u043f\u043e\u043f\u0435\u0440\u0435\u0434\u043d\u0456 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043a\u043e\u043b\u0438 \u0432\u0438 \u043f\u0443\u0431\u043b\u0456\u043a\u0443\u0454\u0442\u0435 \u043d\u043e\u0432\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e. \u0426\u0435 \u0434\u043e\u043f\u043e\u043c\u0430\u0433\u0430\u0454 \u0437\u0431\u0456\u043b\u044c\u0448\u0438\u0442\u0438 \u0442\u0440\u0430\u0444\u0456\u043a \u0456 \u043f\u0440\u0430\u0446\u044e\u0454 \u043f\u043e\u0434\u0456\u0431\u043d\u043e \u0434\u043e \u043f\u043b\u0430\u0433\u0456\u043d\u0456\u0432, \u0442\u0430\u043a\u0438\u0445 \u044f\u043a \u00abRelative Posts\u00bb, \u0430\u043b\u0435 \u0442\u0456\u043b\u044c\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u0456\u0448\u0435.<\/p>\n<p>\u0423\u0441\u0456 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 WordPress \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u044e\u0442\u044c\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0456, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434 <strong>wp_posts<\/strong>, \u0456 \u0432\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0456 \u0446\u0456\u0454\u0457 \u0442\u0430\u0431\u043b\u0438\u0446\u0456 \u0432\u0438 \u0437\u043d\u0430\u0439\u0434\u0435\u0442\u0435 <strong>post_title<\/strong>, <strong>post_name<\/strong>, \u0456 \u0446\u0456 \u0441\u0442\u043e\u0432\u043f\u0446\u0456 \u0434\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0456. \u0417\u0430\u043b\u0435\u0436\u043d\u043e \u0432\u0456\u0434 \u043a\u043e\u043d\u0444\u0456\u0433\u0443\u0440\u0430\u0446\u0456\u0457 URL-\u0430\u0434\u0440\u0435\u0441 \u0432\u0430\u0448\u0438\u0445 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u0430\u0442\u0438 \u0440\u0456\u0437\u043d\u0456 \u0444\u043e\u0440\u043c\u0430\u0442\u0438 \u043f\u043e\u0441\u0442\u0456\u0439\u043d\u0438\u0445 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u044c, \u044f\u043a\u0456 \u043c\u043e\u0436\u043d\u0430 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0432 \u0440\u043e\u0437\u0434\u0456\u043b\u0456 \u041d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u043d\u043d\u044f \u2013 \u041f\u043e\u0441\u0442\u0456\u0439\u043d\u0435 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f.<\/p>\n<p>\u041d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043d\u0438\u0436\u0447\u0435 \u043a\u043e\u0434 PHP \u043c\u043e\u0436\u043d\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438, \u044f\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, <strong>single.php<\/strong>, \u044f\u043a\u0438\u0439 \u0454 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u0454\u0434\u0438\u043d\u043e\u0457 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u0430\u0431\u043e <strong>page.php<\/strong> \u0434\u043b\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438.<\/p>\n<pre><code>\u00a0 global $wpdb; \/\/ include the $wpdb\n\u00a0 $query = \"select `post_title` as `title`, `post_name` as `name` from `wp_posts` where `post_type`='post' and `post_status`='publish' order by rand() limit 1\";\n\u00a0 $results = $wpdb-&gt;get_results($query); \/\/ run the query on the database\n\u00a0 if ($results) { \n\u00a0 \u00a0 $domain = $_SERVER['SERVER_NAME'];\n\u00a0 \u00a0 foreach ($results as $toppost) {\n\u00a0 \u00a0 \u00a0 \u00a0 echo \"&lt;a href=\"&lt;a class=\"vglnk\" target=\"_blank\" href=\"http:\/\/$domain\/\".$toppost-\" rel=\"nofollow\"&gt;&lt;span&gt;http&lt;\/span&gt;&lt;span&gt;:\/\/$&lt;\/span&gt;&lt;span&gt;domain&lt;\/span&gt;&lt;span&gt;\/\".$&lt;\/span&gt;&lt;span&gt;toppost&lt;\/span&gt;&lt;span&gt;-&lt;\/span&gt;&lt;\/a&gt;&gt;name.\"\/\"&gt;&lt;img title=\"Next Post: \".$toppost-&gt;title.\"\" src=\"&lt;a class=\"vglnk\" target=\"_blank\" href=\"https:\/\/helloacm.com\/static\/nextpost2.png\" 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;span&gt;\/&lt;\/span&gt;&lt;span&gt;static&lt;\/span&gt;&lt;span&gt;\/&lt;\/span&gt;&lt;span&gt;nextpost2&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;png&lt;\/span&gt;&lt;\/a&gt;\" alt=\"Next Post: \".$toppost-&gt;title.\"\" \/&gt;&lt;\/a&gt;\";\n\u00a0 \u00a0 }\n\u00a0 }<\/code><\/pre>\n<p>\u0417\u043c\u0456\u043d\u0456\u0442\u044c <strong>wp_posts<\/strong> \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0446\u0435 \u043c\u043e\u0436\u0435 \u0434\u0435\u0449\u043e \u0432\u0456\u0434\u0440\u0456\u0437\u043d\u044f\u0442\u0438\u0441\u044f. SQL-\u0437\u0430\u043f\u0438\u0442 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u0434\u043e\u0432\u0456\u043b\u044c\u043d\u0438\u0439 \u0434\u043e\u043f\u0438\u0441, \u0434\u0435 \u0432\u0456\u043d \u0432\u0438\u043a\u043b\u044e\u0447\u0430\u0454 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438 \u0430\u0431\u043e \u043f\u0443\u043d\u043a\u0442\u0438 \u043c\u0435\u043d\u044e, \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u0442\u043e\u0449\u043e. \u0406 \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 \u043e\u043f\u0443\u0431\u043b\u0456\u043a\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0434\u043e\u043f\u0438\u0441\u0443, \u044f\u043a\u0438\u0439 \u0432\u0438\u043a\u043b\u044e\u0447\u0430\u0454 \u0447\u0435\u0440\u043d\u0435\u0442\u043a\u0443. \u041e\u0431\u043c\u0435\u0436\u0435\u043d\u043d\u044f <strong>1<\/strong> \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u043b\u0438\u0448\u0435 1 \u0434\u043e\u043f\u0438\u0441. \u041e\u0442\u0436\u0435, \u044f\u043a\u0449\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u0430 \u043f\u043e\u043f\u0435\u0440\u0435\u0434\u043d\u044f \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044f, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0446\u0435 \u043d\u0430 <strong>\u043e\u0431\u043c\u0435\u0436\u0435\u043d\u043d\u044f 2<\/strong>.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0456\u0439\u043d\u0435 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u043c\u043e\u0454\u043c\u0443 \u0441\u0430\u0439\u0442\u0456 \u0431\u0430\u0437\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430 <strong>post_name<\/strong>, \u0449\u043e \u0454 \u0431\u0456\u043b\u044c\u0448 \u0437\u0440\u0443\u0447\u043d\u0438\u043c \u0434\u043b\u044f SEO. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0446\u0435. \u0417\u0430\u043f\u0438\u0442 SQL \u0442\u0430\u043a\u043e\u0436 \u043c\u043e\u0436\u043d\u0430 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0438 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u0456 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u0437\u0430\u043c\u0456\u0441\u0442\u044c \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u0445 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439, \u0437\u0456\u0441\u0442\u0430\u0432\u0438\u0432\u0448\u0438 <code>title<\/code>\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0457 \u043d\u0430\u0437\u0432\u0438 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457. \u0410\u0431\u043e \u0432\u0438 \u0441\u043f\u0440\u0430\u0432\u0434\u0456 \u0431\u0430\u0436\u0430\u0454\u0442\u0435 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0438 \u043f\u043e\u043f\u0435\u0440\u0435\u0434\u043d\u044e \u0447\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e, \u0432\u0456\u0434\u0441\u043e\u0440\u0442\u043e\u0432\u0430\u043d\u0443 \u0437\u0430 \u0434\u0430\u0442\u043e\u044e \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0442\u0438 \u043f\u043e\u043b\u0435 &quot;post_id&quot;.<\/p>\n<h3>\u041a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0456<\/h3>\n<p>\u042e \u2013 &#8220;\u041a\u0440\u0443\u0442\u043e, \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u0439 \u0432\u0438\u0431\u0456\u0440 \u2013 \u0446\u0435 \u0434\u0443\u0436\u0435 \u043f\u0440\u0438\u0454\u043c\u043d\u043e. \u0422\u0430\u043a\u043e\u0436 \u043a\u0440\u0430\u0449\u0435 \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0442\u0438\u0441\u044f, \u0449\u043e \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0430 \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0430 \u0437 \u043f\u043e\u0442\u043e\u0447\u043d\u043e\u044e \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0454\u044e. \u0410\u043b\u0435 \u0437\u0430\u0437\u0432\u0438\u0447\u0430\u0439 \u0446\u0435 \u043d\u0435 \u0454 \u0432\u0435\u043b\u0438\u043a\u043e\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u044e, \u044f\u043a\u0449\u043e \u0431\u043b\u043e\u0433 \u043f\u0440\u0438\u0441\u0432\u044f\u0447\u0435\u043d\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0436\u0430\u043d\u0440\u0443.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0436 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e RAND() \u0434\u043e\u0431\u0440\u0435 \u043f\u0440\u0430\u0446\u044e\u0454 \u0434\u043b\u044f \u0442\u0438\u0441\u044f\u0447 \u0437\u0430\u043f\u0438\u0441\u0456\u0432. (\u0437\u0430\u0437\u0432\u0438\u0447\u0430\u0439 \u0446\u0435 \u0441\u0442\u043e\u0441\u0443\u0454\u0442\u044c\u0441\u044f \u0437\u0432\u0438\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u0433\u0443). \u0410\u043b\u0435 \u0446\u0435 \u0441\u043f\u0430\u043b\u0438\u0442\u044c \u0432\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u0438\u0445, \u044f\u043a\u0449\u043e \u0443 \u0432\u0430\u0441 \u0454 \u043c\u0456\u043b\u044c\u0439\u043e\u043d\u0438 \u0437\u0430\u043f\u0438\u0441\u0456\u0432 \u0432 \u043e\u0434\u043d\u0456\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0456, \u044f\u043a\u0430 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0430\u0454 \u043a\u0440\u0438\u0442\u0435\u0440\u0456\u044f\u043c \u043f\u043e\u0448\u0443\u043a\u0443\u00bb.<\/p>\n<p>\u0422\u0430\u043a, \u043f\u043e\u0440\u044f\u0434\u043e\u043a SQL <strong>\u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e rand()<\/strong> \u0454 \u0442\u0440\u043e\u0445\u0438 \u0441\u043a\u043b\u0430\u0434\u043d\u0438\u043c \u0456 \u043f\u043e\u0432\u0456\u043b\u044c\u043d\u0438\u043c. \u0412\u0456\u043d \u043f\u043e\u0432\u0438\u043d\u0435\u043d \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0432\u0441\u0456 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u0430 \u0432\u0456\u0434\u0441\u043e\u0440\u0442\u0443\u0432\u0430\u0442\u0438 \u0457\u0445 \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u043c \u0447\u0438\u043d\u043e\u043c. \u0412\u0432\u0430\u0436\u0430\u0454\u0442\u044c\u0441\u044f \u043d\u0438\u0437\u044c\u043a\u043e\u044e \u0435\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0456\u0441\u0442\u044e, \u043a\u043e\u043b\u0438 \u0440\u043e\u0437\u043c\u0456\u0440 \u0441\u0442\u043e\u043b\u0443 \u0441\u0435\u0440\u0435\u0434\u043d\u0456\u0439 \u0430\u0431\u043e \u0432\u0435\u043b\u0438\u043a\u0438\u0439. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0442\u0438\u0441\u044f \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u043c \u0442\u0440\u044e\u043a\u043e\u043c, \u0449\u043e\u0431 \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0438\u0441 \u0448\u0432\u0438\u0434\u0448\u0435, \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u044e\u0447\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e <strong>rand()<\/strong> \u0443 PHP.<\/p>\n<pre><code>\/\/ get total number of records\n$query = \"select count(1) from `table`\";\n$result = mysql_query($query) or die(mysql_error());\n$total = mysql_result($result, 0, 0);\n\n\/\/ get a random\n$r = rand(0, $total - 1);\n\/\/ return a number between 0 and $total - 1 inclusive using PHP\n$query = \"select * from `table` limit $r, 1\";\n$result = mysql_query($query) or die(mysql_error());<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0438 \u043e\u0431\u043c\u0435\u0436\u0435\u043d\u043d\u044f<\/strong> SQL \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u044e\u0442\u044c \u0437\u0441\u0443\u0432, \u0430 \u0434\u0440\u0443\u0433\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u0454 \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0456\u0432, \u044f\u043a\u0456 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438.<\/p>\n<h3>\u041a\u0440\u0430\u0449\u0438\u0439 \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0438\u0441<\/h3>\n<p>\u0412\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0432\u0438\u0449\u0435\u0437\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e\u0433\u043e, <strong>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e rand()<\/strong> \u0454 \u043d\u0430\u0434\u0437\u0432\u0438\u0447\u0430\u0439\u043d\u043e \u043d\u0435\u0435\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0438\u043c, \u044f\u043a\u0449\u043e \u0443 \u0432\u0430\u0441 \u0434\u0443\u0436\u0435 \u0432\u0435\u043b\u0438\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044f, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0443\u0432\u0430\u043d\u043d\u044f (\u043d\u0430\u0432\u0456\u0442\u044c \u044f\u043a\u0449\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u0435\u043d \u043b\u0438\u0448\u0435 \u043e\u0434\u0438\u043d \u0435\u043b\u0435\u043c\u0435\u043d\u0442), \u0431\u0443\u0434\u0435 \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0456\u044f <strong>rand()<\/strong>, \u0430 \u0446\u0435 \u0442\u0435, \u0447\u043e\u0433\u043e \u043c\u0438 \u043d\u0435 \u0440\u043e\u0431\u0438\u043c\u043e. \u0445\u043e\u0447\u0443\u0442\u044c. \u041c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u043f\u043e\u043a\u0440\u0430\u0449\u0438\u0442\u0438 \u0432\u0438\u0449\u0435\u0437\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0435, \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u044e\u0447\u0438 \u0434\u0432\u0430 \u0437\u0430\u043f\u0438\u0442\u0438, \u043f\u0435\u0440\u0448\u0438\u0439 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u0437\u0430\u0433\u0430\u043b\u044c\u043d\u0443 \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044c \u0434\u043e\u043f\u0438\u0441\u0456\u0432, \u0456 \u043c\u0438 \u043c\u0430\u0454\u043c\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u0438\u0431\u043e\u0440\u0443 PHP \u0456 \u043e\u0442\u0440\u0438\u043c\u0443\u0454\u043c\u043e \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0438\u0441 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <strong>limit .<\/strong><\/p>\n<pre><code>global $wpdb; \/\/ include the $wpdb\n$query= \"select count(1) from `wp_posts` where `post_type`='post' and `post_status`='publish'\";\n$cnt = $wpdb-&gt;get_var($query); \/\/ run the query on the database and return single variable\n$rand = mt_rand(0, $cnt - 1);\n$query= \"select `post_title` as `title`, `post_name` as `name` from `wp_posts` where `post_type`='post' and `post_status`='publish' limit $rand,1\";\n$results = $wpdb-&gt;get_results($query); \/\/ run the query on the database\n\/\/ the rest are the same<\/code><\/pre>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0443 \u0434\u043e\u0432\u0456\u043b\u044c\u043d\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438 WordPress<\/p>\n","protected":false},"author":1,"featured_media":224094,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[902,725,1110,808,808,839,849,869,869,839,902,849,725],"tags":[1174],"class_list":{"0":"post-233264","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-kod-3","8":"category-rozrobnyk","9":"category-n-a","10":"category-php-10","12":"category-kerivnytstvo-dlia-pochatkivtsiv","13":"category-pidruchnyky","14":"category-wordpress-10","20":"tag-affiai-uk"},"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/comments?post=233264"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233264\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/224094"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=233264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=233264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=233264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}