{"id":11348,"date":"2010-11-01T08:00:00","date_gmt":"2010-11-01T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/all-inclusive\/"},"modified":"2022-01-09T15:38:00","modified_gmt":"2022-01-09T15:38:00","slug":"all-inclusive","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/all-inclusive\/","title":{"rendered":"All Inclusive"},"content":{"rendered":"<p>The pluginplug-in, with two additional SQL queries, joins the original data sample $wp_query->posts all meta fields, all files and images, for each image the direct url to small, medium, and large image is formed. There\u2019s no need to use functions the_post_thumbnail  and get_post_meta.<\/p>\n<h4>How it works<\/h4>\n<p>So let\u2019s say we go to the home page of our blog, WordPress gives us a list of the latest 10 records. Let me remind you these are already in the global object in the array $wp_query-> posts. Let\u2019s begin from creating a list of ID (number of records to which they are stored in the database).<\/p>\n<h4>Form the first SQL query:<\/h4>\n<ul>\n<li>$query = \u201cSELECT $wpdb->posts.* FROM $wpdb->posts WHERE  $wpdb->posts.post_parent IN(\u201921\u2019,\u201929\u2019,\u201930\u2019,\u201935\u2019,\u201938\u2019,\u201942\u2019,\u201946\u2019,\u201948\u2019,\u201949\u2019,\u201955\u2019) AND $wpdb->posts.post_parent<br \/>\nAND $wpdb->posts.post_type = \u2018attachment'\u201d;<\/li>\n<\/ul>\n<p>A normal translation is \u00abfind all the child entries for entries with the numbers (\u201921 \u2018, \u201929?, \u201930 \u2018, \u201935?, \u201938 \u2018, \u201942?, \u201946 \u2018, \u201948?, \u201949 \u2018, \u201955 \u2018)\u00bb. And the type of records required to be \u00abattachment\u00bb. That is, in short, we find all the files (attachment) which we downloaded for our 10 entries.<\/p>\n<p>Again we form a list of ID: the first 10 ID entries and add the ID of files (attachments). Attachments as ordinary records are stored in one table \u2013 wp_posts.<\/p>\n<h4>Now we use the function update_meta_cache:<\/h4>\n<ul>\n<li>$all_meta = update_meta_cache(\u2018post\u2019, $ar_all_id);<\/li>\n<\/ul>\n<p>$ar_all_id \u2013 here are the original recordings and attachments<\/p>\n<p>So everything just gets in the cache and subsequent calls get_post_meta will derive value from the cache. The rest is a matter of technique \u2013 the data must be carefully arranged, not mixing anything up. All meta fields are added to the $post->meta array, and files into an $post->files array and files are immediately sorted by number order (when downloading it, you can specify the sort order).<br \/>\nIn addition, for each file, if it is an image, the full path to the thumbnails is calculated: small (thumbnail), average (medium) and the complete picture (full).<\/p>\n<h4>WordPres 4:<\/h4>\n<p>The default filter is only connected to the main query using is_main_query().<br \/>\nDoes not work in is_admin() or is_page().<\/p>\n<p><a href=\"http:\/\/bugacms.com\/wpEn\/all-inclusive\/\" rel=\"nofollow ugc\">Home page<\/a><br \/>\n<a href=\"http:\/\/bugacms.com\/wpRu\/all-inclusive\/\" rel=\"nofollow ugc\">\u0420\u0443\u0441\u0441\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/a><\/p>\n<h3>A brief Markdown Example<\/h3>\n<p><a href=\"http:\/\/bugacms.com\/wpEn\/all-inclusive\/\" rel=\"nofollow ugc\">More PHP code Examples<\/a><br \/>\n<a href=\"http:\/\/bugacms.com\/wpRu\/all-inclusive\/\" rel=\"nofollow ugc\">\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The pluginplug-in, with two additional SQL queries, joins the original data sample $wp_query->posts all meta fields, all files and images.<\/p>\n","protected":false},"author":65,"featured_media":232821,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"All Inclusive - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"The pluginplug-in, with two additional SQL queries, joins the original data sample $wp_query->posts all meta fields, all files and images."},"footnotes":""},"categories":[1],"tags":[223,155,71,542,986],"class_list":["post-11348","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-image","tag-meta","tag-post","tag-posts","tag-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/11348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=11348"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/11348\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/232821"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=11348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=11348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=11348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}