[wordpress插件] All Inclusive全包

wordpress 插件 文章 2020-02-16 05:20 577 0 全屏看文

AI助手支持GPT4.0

评分

0

0

描述

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.

具有两个附加SQL查询的pluginplug-in联接原始数据样本$ wp_query->发布所有元字段,所有文件和图像,对于每个图像,形成指向小,中,大图像的直接url。

There’s no need to use functions the_post_thumbnail and get_post_meta.

无需使用the_post_thumbnail和get_post_meta函数。

How it works

工作原理

So let’s say we go to the home page of our blog, WordPress gives us a list of the latest 10 records.

因此,假设我们转到博客的首页,WordPress会向我们提供最近10条记录的列表。

Let me remind you these are already in the global object in the array $wp_query-> posts.

让我提醒您,这些已经在$ wp_query-> posts数组的全局对象中。

Let’s begin from creating a list of ID (number of records to which they are stored in the database).

让我们从创建ID列表(存储在数据库中的记录数)开始。

Form the first SQL query:

形成第一个SQL查询:

    • $query = “SELECT $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN('21','29','30','35','38'

    • $ query =“ SELECT $ wpdb-> posts。* FROM $ wpdb-> posts WHERE $ wpdb-> posts.post_parent IN('21','29','30','35','38'

      ,'42','46','48','49','55') AND $wpdb->posts.post_parent

      ,'42','46','48','49','55')和$ wpdb-> posts.post_parent

      AND $wpdb->posts.post_type = ‘attachment'”;

    • AND $ wpdb-> posts.post_type ='attachment'”;

    A normal translation is «find all the child entries for entries with the numbers ('21 ', '29?, '30 ', '35?, '38 ', '42?, '46 ', '48?

    通常的翻译是«找到所有子条目以获取带有数字(“ 21”,“ 29”,“ 30”,“ 35”,“ 38”,“ 42”,“ 46”,“ 48?

    , '49 ', '55 ')».

    ,'49','55')»。

    And the type of records required to be «attachment».

    并且记录类型必须为“附件”。

    That is, in short, we find all the files (attachment) which we downloaded for our 10 entries.

    简而言之,我们找到了我们为10个条目下载的所有文件(附件)。

    Again we form a list of ID: the first 10 ID entries and add the ID of files (attachments).

    同样,我们形成一个ID列表:前10个ID条目,并添加文件(附件)的ID。

    Attachments as ordinary records are stored in one table – wp_posts.

    附件作为普通记录存储在一个表中– wp_posts。

    Now we use the function update_meta_cache:

    现在,我们使用功能update_meta_cache:

      • $all_meta = update_meta_cache(‘post’, $ar_all_id);
      • $ all_meta = update_meta_cache('post',$ ar_all_id);

      $ar_all_id – here are the original recordings and attachments

      $ ar_all_id –这是原始录音和附件

      So everything just gets in the cache and subsequent calls get_post_meta will derive value from the cache.

      因此,所有内容都将进入缓存,后续调用get_post_meta将从缓存中获取值。

      The rest is a matter of technique – 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).

      所有元字段都添加到$ post-> meta数组中,文件放入$ post-> files数组,并且文件立即按数字顺序排序(下载时,您可以指定排序顺序)。

      In 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).

      此外,对于每个文件(如果是图像),将计算缩略图的完整路径:小(缩略图),平均值(中)和完整图片(完整)。

      WordPres 4:

      WordPres 4:

      The default filter is only connected to the main query using is_main_query().

      默认过滤器仅使用is_main_query()连接到主查询。

      Does not work in is_admin() or is_page().

      在is_admin()或is_page()中不起作用。

      Home page

      首页

      Details

      详细信息

      A brief Markdown Example

      一个简短的Markdown示例

      Examples

      示例

      Details

      详细信息

安装步骤

    1. Upload all-inclusive.php to the /wp-content/plugins/ directory
    2. all-inclusive.php 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    Access to metadata fields recording

    访问记录元数据的字段

      • $post->meta['meta_name'] or $post->meta_name
      • $ post-> meta ['meta_name'] $ post-> meta_name

      Get files

      获取文件

        • $post->files[0]->attachment_url Direct Link
        • $ post->文件[0]-> attachment_url 直接链接

        • $post->files[0]->guid the first file parameter guid is the same direct link
        • $ post-> files [0]-> guid 第一个文件参数guid是相同的直接链接

        Get images and thumbnail

        获取图像和缩略图

          • $post->files[0]->thumbnail First Image Thumbnail
          • $ post-> files [0]->缩略图第一张图片缩略图

          • $post->files[1]->thumbnail second file is a miniature
          • $ post-> files [1]->缩略图第二个文件是一个微型

          • $post->files[2]->medium the third file is the average miniature
          • $ post-> files [2]-> medium 第三个文件是平均缩图

          • $post->files[3]->full fourth file is a complete picture
          • $ post-> files [3]-> full 第四个文件是完整图片

          More PHP code Examples

          更多PHP代码示例

下载地址

https://downloads.wordpress.org/plugin/all-inclusive.zip

https://downloads.wordpress.org/plugin/all-inclusive.zip

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
[wordpress插件] Advanced Custom Fields: Menu Field高级自定义字段:菜单字段
[wordpress插件] baseballNuke棒球
[wordpress插件] Aidah LiveChat艾达LiveChat
[wordpress插件] Async JS and CSS异步JS和CSS
[wordpress插件] azurecurve Display After Post Content发布内容后的azurecurve显示
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048
如何快速搭建抽奖助手小程序(无需代码知识) 6177
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 7472
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 6793
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 6128
如何解决渲染层网络错误Failed to load media? 17394
小程序找号找回 释放昵称? 3253
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 3110
删除部分微信用户个人数据的通知,怎么删除? 6381