0

我试图代码我的wordpress主题尽可能简单,但我真的不明白,为什么我不能显示从高级定制字段中的图像进入模式对话框打开一个高级自定义字段图像使用Featherlight.js一个模式对话框(http://noelboss.github.io/featherlight/WordPress的 - 使用Featherlight.js

这是我在网上http://www.skuar.com页面

这是我的single.php代码,它只是显示图像的自定义字段

<?php if (have_posts()) : ?> 
    <?php while (have_posts()) : the_post(); ?> 

<?php 

$image = get_field('image'); 

if(!empty($image)): ?> 

    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> 

<?php endif; ?> 

    <?php endwhile; ?> 
    <?php endif; ?> 

,这是wp循环c ontent

<div id="post"> 
    <a href ="<?php the_permalink(); ?>"> 

    <div class="img" href="<?php 

$image = get_field('image'); 

if(!empty($image)): ?> 

    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> 

<?php endif; ?>" data-featherlight="image"> 
<?php 

$image = get_field('image'); 

if(!empty($image)): ?> 

    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> 

<?php endif; ?> 
    </div> 

    </a> 

</div> 

我只是想在灯箱打开图像... 是这样有意义吗?

谢谢!

回答

0

代码中的无效双引号。试试这个代码:

<div id="post"> 
     <a href ="<?php the_permalink(); ?>"> 
      <div class="img" href="<?php $image = get_field('image'); 
       if(!empty($image)): ?> 
       <?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?> 
       <?php endif; ?>" data-featherlight="image"> 
      </div> 
     </a> 
    </div> 
+0

真棒。它解决了我的问题。但实际上很奇怪,它在我的本地服务器(使用MAMP)上运行良好,但不在线。我刚刚上传了完全相同的文件。你知道为什么吗? – levystore

+0

它在现场工作吗? – vel

+0

现在都很好,我只是用mydomain.com/js /替换/ js/... – levystore