【问题标题】:How to set post content's first image to be thumbnail image for more than 1000 records?如何将帖子内容的第一张图片设置为超过 1000 条记录的缩略图?
【发布时间】:2019-02-12 14:28:10
【问题描述】:

您好,我从 CSV 文件中导入了 1000 多个帖子,因此其中大多数都没有特色图片。我尝试安装有助于根据帖子内容自动更新特色图像的插件,但它们在 Wordpress 4.9.7 中不起作用。 是否有任何解决方案或插件可以帮助我做到这一点?

【问题讨论】:

    标签: wordpress thumbnails posts


    【解决方案1】:

    尝试使用插件,这样你就可以得到相同的解决方案-

    第一个插件 - 分享插件链接,点击链接 - WordPress Importer

    第二个插件-分享插件链接,点击链接-Auto Upload Images

    希望!!它对你有用..

    【讨论】:

      【解决方案2】:

      我不知道是否有一个插件,但如果你想自己做,这里是代码 您将需要在数组中收集帖子 ID,比如说“posts_ids”

      $posts_ids = array();
      foreach ( $posts_ids as $post_id ) {
          $attachments = get_attached_media( 'image', $post_id );
          if ( ! empty( $attachments ) ) {
              set_post_thumbnail( $post_id , array_keys( $attachments )[0] );
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2012-11-23
        • 1970-01-01
        • 1970-01-01
        • 2014-09-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-31
        • 2013-02-04
        相关资源
        最近更新 更多