用wordpress替换图像链接

时间:2013-03-27 17:09:28

标签: wordpress

我不确定如何将图像替换为下面回显的链接。目前,这显示了一个链接,但我想使其成为可点击的图像而不是链接。提前谢谢你:)

<div class="back-button">
    <?php
        $this_page = get_post($id);
        $parent_id = $this_page->post_parent;
        if ($parent_id) {
            $parent = get_page($parent_id);
            echo '<a href="'.get_permalink($parent->ID).'" title="">'.get_the_title($parent->ID).'</a>';
        }
    ?>

我明白了!这是解决方案:

                <?php
                $this_page = get_post($id);
                $parent_id = $this_page->post_parent;
                if ($parent_id) {
                    $parent = get_page($parent_id);
                    echo '<a href="'.get_permalink($parent->ID).'" title="">'.'<img src="' . get_bloginfo("template_directory") . '/images/close-icon.png" />'.'</a>';
                }
            ?>              

2 个答案:

答案 0 :(得分:0)

您只需要在标记内包含img标记:

echo '<a href="'.get_permalink($parent->ID).'" title=""><img src='myImage.png'/></a>';

您只需要将myImage.png替换为您想要的图像的网址。

答案 1 :(得分:0)

<div class="back-button">
<?php
    $this_page = get_post($id);
    $parent_id = $this_page->post_parent;
    if ($parent_id) {
        $parent = get_page($parent_id); ?>  <a href="#" title=""><img src="<?php bloginfo('template_directory')?>/images/imagename.gif"></a> <?php  }  ?>

尝试使用此