{"id":4097,"date":"2024-11-10T17:55:09","date_gmt":"2024-11-10T17:55:09","guid":{"rendered":"https:\/\/forestgreen-jay-845795.hostingersite.com\/?p=4097"},"modified":"2024-11-24T11:46:38","modified_gmt":"2024-11-24T11:46:38","slug":"%d0%bf%d0%be%d0%ba%d0%b0%d0%b7%d0%b0%d1%82%d1%8c-%d0%b7%d0%b0%d0%b3%d0%be%d0%bb%d0%be%d0%b2%d0%ba%d0%b8-%d0%b2%d1%81%d0%b5%d1%85-%d0%b7%d0%b0%d0%bc%d0%b5%d1%82%d0%be%d0%ba-%d0%b1%d0%bb%d0%be%d0%b3","status":"publish","type":"post","link":"https:\/\/newsbee.blog\/wp-tips\/2024\/11\/10\/4097\/","title":{"rendered":"\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a \u0431\u043b\u043e\u0433\u0430"},"content":{"rendered":"<p>\u042d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u0430\u0433\u0438\u043d Code Snippets \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043c\u0435\u0442\u043e\u043a \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043b\u043e\u0433\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438\u043b\u0438 \u0432 \u043f\u043e\u0441\u0442\u0435.<\/p>\n<div class=\"code-block-wrapper\" style=\"position: relative;\">\n        <button class=\"copy-button\" id=\"copy_code_block_69f97dbb3b346\" data-target=\"code_block_69f97dbb3b346\" style=\"\n            position: absolute; \n            top: 10px; \n            right: 10px; \n            background: #0073aa; \n            color: #fff; \n            border: none; \n            padding: 5px 10px; \n            cursor: pointer; \n            font-size: 12px;\n            border-radius: 5px;\">Copy<\/button><\/p>\n<pre><code id=\"code_block_69f97dbb3b346\">\r\nfunction display_all_posts_titles( $atts ) {\r\n    \/\/ Extract shortcode attributes\r\n    $atts = shortcode_atts(\r\n        array(\r\n            &#039;number&#039; =&gt; -1,        \/\/ Default is -1, meaning no limit\r\n            &#039;exclude&#039; =&gt; &#039;&#039;,       \/\/ Default is empty, no posts to exclude\r\n        ),\r\n        $atts,\r\n        &#039;all_posts&#039;\r\n    );\r\n\r\n    \/\/ Convert the exclude string into an array of IDs\r\n    $exclude_ids = array_map(&#039;trim&#039;, explode(&#039;,&#039;, $atts[&#039;exclude&#039;]));\r\n\r\n    \/\/ Set up query arguments for all posts with the specified number limit, excluding sticky posts and specific posts\r\n    $args = array(\r\n        &#039;post_type&#039;           =&gt; &#039;post&#039;,\r\n        &#039;posts_per_page&#039;      =&gt; $atts[&#039;number&#039;], \/\/ Use the number specified in the shortcode\r\n        &#039;orderby&#039;             =&gt; &#039;date&#039;,\r\n        &#039;order&#039;               =&gt; &#039;DESC&#039;,\r\n        &#039;ignore_sticky_posts&#039; =&gt; true, \/\/ Exclude sticky posts\r\n        &#039;post__not_in&#039;        =&gt; $exclude_ids, \/\/ Exclude specific posts\r\n    );\r\n\r\n    \/\/ Query posts\r\n    $query = new WP_Query( $args );\r\n\r\n    \/\/ Begin output\r\n    $output = &#039;&lt;br \/&gt;&#039;;\r\n\r\n    \/\/ Loop through posts and generate list items\r\n    if ( $query-&gt;have_posts() ) {\r\n        while ( $query-&gt;have_posts() ) {\r\n            $query-&gt;the_post();\r\n            $output .= &#039;&lt;li&gt;&lt;a href=&quot;&#039; . get_permalink() . &#039;&quot;&gt;&#039; . get_the_title() . &#039;&lt;\/a&gt;&lt;\/li&gt;&lt;br \/&gt;&#039;;\r\n        }\r\n    } else {\r\n        $output .= &#039;&lt;li&gt;No posts found.&lt;\/li&gt;&#039;;\r\n    }\r\n\r\n    $output .= &#039;&#039;;\r\n\r\n    \/\/ Reset post data\r\n    wp_reset_postdata();\r\n\r\n    return $output;\r\n}\r\nadd_shortcode( &#039;all_posts&#039;, &#039;display_all_posts_titles&#039; );\r\n<\/code><\/pre>\n<\/p><\/div>\n<p>\u0414\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0434\u0430 \u0432 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0438\u043b\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u043e\u0440\u0442\u043a\u043e\u0434:<\/p>\n<div class=\"code-block-wrapper\" style=\"position: relative;\">\n        <button class=\"copy-button\" id=\"copy_code_block_69f97dbb3b353\" data-target=\"code_block_69f97dbb3b353\" style=\"\n            position: absolute; \n            top: 10px; \n            right: 10px; \n            background: #0073aa; \n            color: #fff; \n            border: none; \n            padding: 5px 10px; \n            cursor: pointer; \n            font-size: 12px;\n            border-radius: 5px;\">Copy<\/button><\/p>\n<pre><code id=\"code_block_69f97dbb3b353\">\r\n[all _ posts number=10]\r\n<\/code><\/pre>\n<\/p><\/div>\n<p>NB. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u0431\u0440\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0432 \u0448\u043e\u0440\u0442\u043a\u043e\u0434\u0435. 10 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0446\u0438\u0444\u0440\u0443 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c &#8212; \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0440\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443:<\/p>\n<div class=\"code-block-wrapper\" style=\"position: relative;\">\n        <button class=\"copy-button\" id=\"copy_code_block_69f97dbb3b35a\" data-target=\"code_block_69f97dbb3b35a\" style=\"\n            position: absolute; \n            top: 10px; \n            right: 10px; \n            background: #0073aa; \n            color: #fff; \n            border: none; \n            padding: 5px 10px; \n            cursor: pointer; \n            font-size: 12px;\n            border-radius: 5px;\">Copy<\/button><\/p>\n<pre><code id=\"code_block_69f97dbb3b35a\">\r\n<br \/><li><a href=\"https:\/\/newsbee.blog\/wp-tips\/2026\/02\/06\/5883\/\">\u041a\u0430\u043a \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0442\u0438\u0440\u0435 (\u2014)<\/a><\/li><br \/><li><a href=\"https:\/\/newsbee.blog\/wp-tips\/2025\/11\/21\/5860\/\">\u0411\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0441\u0430\u0439\u0442 \u0441 WP<\/a><\/li><br \/><li><a href=\"https:\/\/newsbee.blog\/wp-tips\/2025\/02\/23\/5799\/\">\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u043b\u043e\u0433\u0430<\/a><\/li><br \/>\r\n<\/code><\/pre>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u042d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u0430\u0433\u0438\u043d Code Snippets \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043c\u0435\u0442\u043e\u043a \u0432\u0430\u0448\u0435\u0433\u043e \u0431\u043b\u043e\u0433\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438\u043b\u0438 \u0432 \u043f\u043e\u0441\u0442\u0435.<\/p>\n <a class=\"read-more-button\" href=\"https:\/\/newsbee.blog\/wp-tips\/2025\/02\/23\/5799\/\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435<\/a>","protected":false},"author":1,"featured_media":4424,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,40],"tags":[39,37],"class_list":["post-4097","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippets","category-shortcodes","tag-snippets","tag-shortcodes"],"_links":{"self":[{"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/posts\/4097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/comments?post=4097"}],"version-history":[{"count":25,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/posts\/4097\/revisions"}],"predecessor-version":[{"id":5161,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/posts\/4097\/revisions\/5161"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/media\/4424"}],"wp:attachment":[{"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/media?parent=4097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/categories?post=4097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newsbee.blog\/wp-tips\/wp-json\/wp\/v2\/tags?post=4097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}