{"id":231798,"date":"2023-01-07T17:49:00","date_gmt":"2023-01-07T14:49:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=231798"},"modified":"2023-01-07T17:50:44","modified_gmt":"2023-01-07T14:50:44","slug":"programnij-poshuk-publikacij-wordpress-za-diapazonom-dat","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/programnij-poshuk-publikacij-wordpress-za-diapazonom-dat\/","title":{"rendered":"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043d\u0438\u0439 \u043f\u043e\u0448\u0443\u043a \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439 WordPress \u0437\u0430 \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0434\u0430\u0442"},"content":{"rendered":"<p><strong>TL; DR:<\/strong> \u043a\u043e\u0434, \u043e\u043f\u0443\u0431\u043b\u0456\u043a\u043e\u0432\u0430\u043d\u0438\u0439 \u0443 \u0446\u0456\u0439 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043f\u043e\u043a\u0430\u0437\u0443\u0454, \u044f\u043a \u043c\u043e\u0436\u043d\u0430 \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0437\u0430\u043f\u0438\u0442, \u044f\u043a\u0438\u0439 \u0432\u0438\u043a\u043e\u043d\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456 \u00ab<strong>\u0423\u0441\u0456<\/strong> \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457\u00bb, \u0449\u043e\u0431 \u043c\u043e\u0436\u043d\u0430 \u0431\u0443\u043b\u043e \u043e\u0431\u043c\u0435\u0436\u0438\u0442\u0438 \u043f\u043e\u0448\u0443\u043a \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439 \u043f\u0435\u0432\u043d\u0438\u043c \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0434\u0430\u0442.<\/p>\n<p>\u041c\u0438\u043d\u0443\u043b\u043e \u043d\u0435\u0431\u0430\u0433\u0430\u0442\u043e \u0447\u0430\u0441\u0443 \u0437 \u0442\u0438\u0445 \u043f\u0456\u0440, \u044f\u043a <a href=\"https:\/\/wordpress.mediadoma.com\/uk\/shukajte-metadani-publikacii-v-oblasti-administruvannja-wordpress\/\" title=\"\u044f \u0432\u043e\u0441\u0442\u0430\u043d\u043d\u0454 \u043f\u0438\u0441\u0430\u0432\">\u044f \u0432\u043e\u0441\u0442\u0430\u043d\u043d\u0454 \u043f\u0438\u0441\u0430\u0432<\/a> \u043f\u0440\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f <code>post_where<\/code>\u0444\u0456\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0457 \u043f\u043e\u0448\u0443\u043a\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0438\u0442\u0443, \u044f\u043a\u0438\u0439 \u0432\u0438\u043a\u043e\u043d\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0432\u043d\u0456\u0439 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0456 \u00ab<strong>\u0423\u0441\u0456 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f<\/strong>\u00bb WordPress. \u0410\u043b\u0435 \u0432\u0440\u0430\u0445\u043e\u0432\u0443\u044e\u0447\u0438 \u0442\u043e\u0439 \u0444\u0430\u043a\u0442, \u0449\u043e \u0456\u0441\u043d\u0443\u0454 \u0431\u0435\u0437\u043b\u0456\u0447 \u0432\u0430\u0440\u0456\u0430\u043d\u0442\u0456\u0432 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u044f \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439 \u2013 \u0456 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0446\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u0456\u0432 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439 \u2013 \u0440\u0456\u0437\u043d\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u0456\u0441\u043d\u0443\u0454 \u0431\u0435\u0437\u043b\u0456\u0447 \u0441\u043f\u043e\u0441\u043e\u0431\u0456\u0432 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0446\u044c\u043e\u0433\u043e \u0454\u0434\u0438\u043d\u043e\u0433\u043e \u0444\u0456\u043b\u044c\u0442\u0440\u0430.<\/p>\n<h2>\u041f\u043e\u0448\u0443\u043a \u0434\u043e\u043f\u0438\u0441\u0456\u0432 \u0437\u0430 \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0434\u0430\u0442<\/h2>\n<p>\u0429\u043e\u0431 \u0448\u0443\u043a\u0430\u0442\u0438 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u0437\u0430 \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0434\u0430\u0442, \u043e\u0441\u044c \u0449\u043e \u043c\u0430\u0454 \u0441\u0442\u0430\u0442\u0438\u0441\u044f:<\/p>\n<ol>\n<li>\u0420\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u044f \u0437\u0432\u043e\u0440\u043e\u0442\u043d\u043e\u0433\u043e \u0434\u0437\u0432\u0456\u043d\u043a\u0430 \u0437 <code>posts_where<\/code>\u0444\u0456\u043b\u044c\u0442\u0440\u043e\u043c,<\/li>\n<li>\u041f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0439\u0442\u0435\u0441\u044f, \u0449\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044f \u043f\u0440\u0438\u0439\u043c\u0430\u0454 \u0440\u044f\u0434\u043e\u043a \u0434\u043b\u044f <code>where<\/code>\u0442\u0430 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, <code>WP_Query<\/code>\u044f\u043a\u0438\u0439 \u0432\u0438\u043a\u043e\u043d\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456<\/li>\n<li>\u041e\u0442\u0440\u0438\u043c\u0430\u0439\u0442\u0435 \u0441\u044c\u043e\u0433\u043e\u0434\u043d\u0456\u0448\u043d\u044e \u0434\u0430\u0442\u0443 \u0439 \u0447\u0430\u0441, \u0430 \u0442\u0430\u043a\u043e\u0436 \u0434\u0430\u0442\u0443 \u0439 \u0447\u0430\u0441 \u0447\u043e\u0442\u0438\u0440\u0438 \u0442\u0438\u0436\u043d\u0456 \u0442\u043e\u043c\u0443<\/li>\n<li>\u0414\u043e\u0434\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u0447\u0435\u043d\u043d\u044f\u043c, <code>where<\/code>\u0449\u043e\u0431 \u043e\u0431\u043c\u0435\u0436\u0438\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438 \u0434\u0430\u0442\u043e\u044e<\/li>\n<li><code>return<\/code>\u043e\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0437\u0430\u043f\u0438\u0442.<\/li>\n<\/ol>\n<pre><code>&lt;?php\nadd_filter( \n  'posts_where',\n  function (string $where, WP_Query $query ): string {\n    global $wpdb;\n\n    $todays_date   = gmdate( 'Y-m-d H:i:s', strtotime( 'now') );\n    $four_weeks_ago = gmdate( 'Y-m-d H:i:s', strtotime( '-4 weeks') );\n\n    $prepend = $wpdb-&gt;prepare(\n      \" AND {$wpdb-&gt;posts}.post_date &gt; %s\",\n      $four_weeks_ago\n    );\n\n    $prepend .= $wpdb-&gt;prepare(\n      \" AND {$wpdb-&gt;posts}.post_date &lt; %s\",\n      $todays_date\n    );\n\n    return $prepend. $where;\n  }, 101, 2\n);<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0446\u0456\u0454\u0457 \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u0454 \u043c\u043e\u0434\u0438\u0444\u0456\u043a\u043e\u0432\u0430\u043d\u0438\u0439 \u0437\u0430\u043f\u0438\u0442, \u044f\u043a\u0438\u0439 \u043e\u0431\u043c\u0435\u0436\u0443\u0454 \u0434\u043e\u043f\u0438\u0441\u0438, \u044f\u043a\u0456 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u044e\u0442\u044c\u0441\u044f \u0434\u043e \u0432\u043a\u0430\u0437\u0430\u043d\u043e\u0457 \u0434\u0430\u0442\u0438 \u0442\u0430 \u0447\u0430\u0441\u0443. \u0410 \u0441\u0430\u043c\u0435 \u0447\u043e\u0442\u0438\u0440\u0438 \u0442\u0438\u0436\u043d\u0456 \u0442\u043e\u043c\u0443 \u0437 \u0442\u043e\u0447\u043d\u0456\u0441\u0442\u044e \u0434\u043e \u0433\u043e\u0434\u0438\u043d\u0438, \u0445\u0432\u0438\u043b\u0438\u043d\u0438 \u0442\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0438.<\/p>\n<p>\u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0446\u0435, \u043e\u043d\u043e\u0432\u0438\u0432\u0448\u0438 <code>-4 weeks<\/code>\u0440\u044f\u0434\u043e\u043a, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0438\u0439 \u0443 <code>strtotime<\/code>\u0444\u0443\u043d\u043a\u0446\u0456\u044e (\u043f\u0440\u043e\u0442\u0435 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u0443\u0442\u0438 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 \u043f\u043e\u0441\u0456\u0431\u043d\u0438\u043a\u0430 PHP, \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u044f\u043a\u0435 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0438\u0436\u0447\u0435, \u0449\u043e\u0431 \u0437\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438, \u044f\u043a \u0446\u044f \u0444\u0443\u043d\u043a\u0446\u0456\u044f \u043f\u0440\u0430\u0446\u044e\u0454 \u0437 \u0442\u0430\u043a\u043e\u044e \u043c\u043e\u0432\u043e\u044e).<\/p>\n<h2>\u0421\u043f\u0438\u0441\u043e\u043a \u043b\u0456\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0438<\/h2>\n<ul>\n<li><code>[posts_where](https:\/\/developer.wordpress.org\/reference\/hooks\/posts_where\/)<\/code><\/li>\n<li><code>[WP_Query](https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/)<\/code><\/li>\n<li><code>[wpdb](https:\/\/developer.wordpress.org\/reference\/classes\/wpdb\/)<\/code><\/li>\n<li><code>[gmdate](https:\/\/www.php.net\/manual\/en\/function.gmdate.php)<\/code><\/li>\n<li><code>[strtotime](https:\/\/www.php.net\/manual\/en\/function.strtotime.php)<\/code><\/li>\n<\/ul>\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=\"\/\/tommcfarlin.com\" class=\"external external_icon\">tommcfarlin.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u0434, \u043d\u0430\u0434\u0430\u043d\u0438\u0439 \u0443 \u0446\u0456\u0439 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043f\u043e\u043a\u0430\u0437\u0443\u0454, \u044f\u043a \u043c\u043e\u0436\u043d\u0430 \u0448\u0443\u043a\u0430\u0442\u0438 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u0437\u0430 \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0434\u0430\u0442 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456 \u00ab\u0423\u0441\u0456 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457\u00bb.<\/p>\n","protected":false},"author":1,"featured_media":158377,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[808,869,839,902,849,725],"tags":[1174],"class_list":["post-231798","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-10","category-wordpress-10","category-kerivnytstvo-dlia-pochatkivtsiv","category-kod-3","category-pidruchnyky","category-rozrobnyk","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/231798","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=231798"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/231798\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/158377"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=231798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=231798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=231798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}