【问题标题】:Alt text not showing echo using wp_get_attachment使用 wp_get_attachment 的替代文本不显示回显
【发布时间】:2017-09-11 16:15:24
【问题描述】:

替代文字未显示...

    $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 这将显示所有内容,但我只需要在循环中回显“alt”文本。

【问题讨论】:

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


【解决方案1】:

利用title标签和alt标签,并可能给它一个宽度和高度,看看这个评论:https://stackoverflow.com/a/8925364/7862006

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

【讨论】:

    猜你喜欢
    • 2017-11-01
    • 1970-01-01
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-21
    • 2014-11-16
    • 1970-01-01
    相关资源
    最近更新 更多