Alt文本未使用wp_get_attachment显示回显

时间:2017-04-15 15:29:57

标签: php wordpress metadata custom-post-type alt

替代文字未显示...

    $images = get_post_meta(get_the_id(), 'vdw_gallery_id', true);



                if( $images ): ?>
                    <ul>
                        <?php foreach( $images as $image ): ?>

                                <li>
                            <a href="<?php echo wp_get_attachment_image_url($image, 'large');  ?>">
                                <img src="<?php echo wp_get_attachment_image_url($image, 'medium'); ?>" alt="Alter TEXT" />
                            </a>
                                </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>             

我尝试了许多方法,但没有得到如何回应改变文本我为画廊创建元字段。

我知道wp_get_attachment_image_src会显示所有内容,但我只需回显&#34; alt&#34;循环内的文字。

1 个答案:

答案 0 :(得分:0)

使用标题标记和alt标记,并可能给它一个宽度和高度,请查看此评论:https://stackoverflow.com/a/8925364/7862006

<img alt="alternative text" title="alternative text" style="min-width: 50px; min-height: 25px;" src="..........
相关问题