wordpress加载fancybox图像数组

时间:2015-02-11 00:39:00

标签: wordpress fancybox

知道为什么下面的代码只是将缩略图加载到fancybox叠加层? .portfolio-slideshow中的图像数组在背景中加载正常,只是没有使用fancybox正确触发。 Wordpress代码:

    <a class="fancybox" href="<?php print $slideshow['guid']; ?>" rel="<?php the_title(); ?>">
        <?php
            if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                the_post_thumbnail();
            }
        ?>

        <div class="portfolio-slideshow">
            <?php
                $slideshow = get_custom_field('portfolio_images:to_array', 'get_post');
                foreach($slideshow as $img) {
            ?>
                <img src="<?php print $img['guid']; ?>" />
            <?php } ?>
        </div>

        <h4><?php the_title(); ?></h4>
    </a>

1 个答案:

答案 0 :(得分:0)

我必须在fancybox链接+ rel标题中包装图像数组,这样做了诀窍:

<div class="portfolio-slideshow">
    <?php
        $slideshow = get_custom_field('portfolio_images:to_array', 'get_post');
        foreach($slideshow as $img) {
    ?>
            <a class="fancybox" href="<?php print $img['guid']; ?>" rel="<?php the_title(); ?>"><img src="<?php print $img['guid']; ?>" /></a>
    <?php } ?>
</div>

<a class="fancybox" href="<?php print $img['guid']; ?>" rel="<?php the_title(); ?>">

<?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
        the_post_thumbnail();
    }
?>

<h4><?php the_title(); ?></h4></a>