简体   繁体   English

批量添加特色图像到现有的Wordpress帖子

[英]Bulk add featured image to existing Wordpress posts

I have cca 4500 posts in my Wordpress backend. 我的Wordpress后端有cca 4500帖子。 Some posts doesn't have featured image. 有些帖子没有精选图片。 I was wondering is there any solution to bulk add featured image (placeholder if there is no "real" image)? 我想知道是否有任何解决方案批量添加精选图像(占位符,如果没有“真实”图像)? I'm talking about backend, I now that I can do on front end but need way to add featured image in the backend if featured image is empty. 我在谈论后端,我现在可以在前端做,但如果特色图像为空,则需要在后端添加特色图像。 Can anybody help me with this? 任何人都可以帮我吗?

You can do this using 3 ways. 你可以用3种方法做到这一点。

  1. Using plugin 使用插件

https://wordpress.org/plugins/default-featured-image/ https://wordpress.org/plugins/default-featured-image/

  1. Or you can show dummy image to your code (when there is no featured image found) 或者,您可以在代码中显示虚拟图像(当找不到特色图像时)

check below code for front-end 检查以下代码的前端

<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
  1. AJAX in Admin (In custom form) - You can also achieve same using creating one option page in backend where you can give form with one image field, and on save you can update featured image if blank found using ajax. Admin中的AJAX(以自定义格式)-您还可以通过在后端创建一个选项页来实现相同目的,在该选项页中可以给一个图像字段提供表单,并且在保存时可以更新特色图像(如果使用ajax找到空白)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM