wordpress - 无法导入图库的任何图片
问题描述
我正在使用 Essential Real Estate 插件和 WP All Import。启动导入我希望获得包含图像的项目,但我只看到所有项目列表中的帖子缩略图。问题是我需要将画廊的缩略图添加到某个项目的页面。有一个自定义字段real_estate_property_gallery
,但即使我使用它和一个值作为随机静态图像(WP All Import),我得到一个空图像并且画廊没有显示它。
我怎样才能把它放到画廊里?
所有图像都存在,它们来自外部站点的 URL。代码gallery.php
:
<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
global $post;
$property_gallery = get_post_meta(get_the_ID(), ERE_METABOX_PREFIX . 'property_images', true);
wp_enqueue_style('owl.carousel');
wp_enqueue_script('owl.carousel');
if ($property_gallery):
$property_gallery = explode('|', $property_gallery); ?>
<div class="single-property-element property-gallery-wrap">
<div class="ere-property-element">
<div class="single-property-image-main owl-carousel manual ere-carousel-manual">
<?php
$gallery_id = 'ere_gallery-' . rand();
foreach ($property_gallery as $image):
$image_src = ere_image_resize_id($image, 870, 420, true);
$image_full_src = wp_get_attachment_image_src($image, 'full');
if (!empty($image_src)) {
?>
<div class="property-gallery-item ere-light-gallery">
<img src="<?php echo esc_url($image_src) ?>" alt="<?php the_title(); ?>"
title="<?php the_title(); ?>">
<a data-thumb-src="<?php echo esc_url($image_full_src[0]); ?>"
data-gallery-id="<?php echo esc_attr($gallery_id); ?>"
data-rel="ere_light_gallery" href="<?php echo esc_url($image_full_src[0]); ?>"
class="zoomGallery"><i
class="fa fa-expand"></i></a>
</div>
<?php } ?>
<?php endforeach; ?>
</div>
<div class="single-property-image-thumb owl-carousel manual ere-carousel-manual">
<?php
foreach ($property_gallery as $image):
$image_src = ere_image_resize_id($image, 250, 130, true);
if (!empty($image_src)) { ?>
<div class="property-gallery-item">
<img src="<?php echo esc_url($image_src) ?>" alt="<?php the_title(); ?>"
title="<?php the_title(); ?>">
</div>
<?php } ?>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
解决方案
推荐阅读
- jquery - 在更改上一个下拉菜单时设置下一个下拉菜单的值
- qt - 将参数传递给 MessageDialog 以根据用户与对话框的交互进一步处理它
- asp.net - 使用 Asp Net Core Nginx 多域重复侦听错误
- sql-server - 从 SQL Server 中的派生表中删除?
- hashmap - 如何将任何类对象存储在哈希映射中
- python - 我有 200 个印地语文本文件。想要删除特殊字符的空格并在python中找到查找二元组和三元组
- python - 在python中创建一个动态插入查询以将数据保存在mysql db中
- angular - 在组件生成时删除 nativescript 角度上的 .Spec 文件
- javascript - 如何在 html 表格中应用内边框
- java - 使用 Aspectj 加载时间编织来记录我的源代码(包括测试)而不记录外部库