【问题标题】:How to insert a image in WordPress that will display on admin product image?如何在 WordPress 中插入将显示在管理产品图像上的图像?
【发布时间】:2014-08-26 08:51:33
【问题描述】:

$insert = $wpdb->insert( $prefix."posts", array("post_title" => $postTitle,"post_content" => $postContent,"post_status" => "publish","post_type" = >“产品”));

我在 wordpress 帖子表中插入图像路径,并且帖子父级包含产品 ID 的 ID,还在 postmeta 表产品 ID 中添加 _thumbnail_id 我的主要重点是在 wp-admin 的帖子产品页面中显示图像

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    图像将插入到postmeta 表中,并带有相关帖子的ID。如果您使用的是 WordPress 的默认帖子,您可以使用函数 get_the_post_thumbnail( $post_id, $size, $attr ); 获取图像,或者您可以从 postmeta 获取这些图像。

    【讨论】:

    • 请参阅我有 woo commerce 产品插件并在产品 ID 下的帖子表中插入图像路径,其中我在图像 post_parent 以及产品 ID 的 postmeta 元键 _thumbnail_id 中使用产品 ID
    【解决方案2】:

    您可以使用函数 get_the_post_thumbnail( $post_id, $size, $attr );也适用于自定义帖子类型。
    见链接 http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2018-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多