0

我正在使用自定义元数据将图像显示为 wordpress 中的帖子。当我单击主页上的图像时,它会在颜色框中打开,这是完美的。

发生了什么:现在,将图像加载到颜色框中,当我单击图像时,它会循环浏览我主页上的图像(不是我想要的)。

我希望发生的事情:将图像加载到颜色框中,当我单击它时,它将充当链接并将帖子(与该图像相关联)加载到颜色框中。

我不清楚如何做到这一点。我用来显示帖子图像元数据的代码是:

        <?php

        // check for spine image
        $spine = get_post_meta($post->ID, 'spine image', $single = true);

        // check for spine class
        $spine_class = get_post_meta($post->ID, 'spine class', $single = true);

    ?>

    <div style=" #position: center; #left: 50%; height: 650px; display: table-cell; vertical-align: middle;">

        <div class="post" id="post-<?php the_ID(); ?>">

            <div class="entry">

                <?php

                    // If there is a spine image, display it as the post
                    if($spine !== '') { ?>

                    <p>
                        <a rel="bookmark" href="<?php echo $spine; ?>" title="<?php the_title_attribute(); ?>">
                            <img src="<?php echo $spine; ?>" class="<?php if($spine_class !== '') { echo $spine_class; } else { echo "left"; } ?>"
                                height="400" onMouseOver='resizeImg(this, 150)' onMouseOut='resizeImg(this)'
                            />
                        </a>
                    </p>

                    <?php } // end if statement

                    // if there's not a spine image
                    else { echo ''; }
                ?>

            </div>

        </div>

    </div>

我用于颜色框的功能是:

<script type="text/javascript">
$(document).ready(function(){
    //Examples of how to assign the ColorBox event to elements
    $("a[rel='bookmark']").colorbox({transition:"fade"});
});
</script>

这样带有“书签”属性的链接将在颜色框中打开。现在我怎样才能使颜色框中的图像链接到相关网页(或充当任何网页的链接......一次一步)?

我希望这是有道理的,谢谢你的帮助,mlord

4

1 回答 1

1

一旦我意识到如何做到这一点,我的问题似乎过于复杂。

最终结果是我使用了网站 ( http://colorpowered.com/colorbox/core/example4/index.html ) 中的“.inline”HTML 结构化示例。我可以将 wordpress 循环中的图像href'd 放到永久链接中,并将其称为内联,以便在颜色框中显示每个图像/帖子。然后我在该链接上包含了通用颜色框类,该链接也打开了颜色框内的帖子。惊人的!

保重,马修

于 2009-09-30T07:31:39.917 回答