【问题标题】:Empty alt tags wordpress空的 alt 标签 wordpress
【发布时间】:2019-12-24 22:35:46
【问题描述】:

我正在使用带有 Listingpro 模板的 WordPress,我一直在寻找解决方案,我发现了以下内容:

// An attachment/image ID is all that's needed to retrieve its alt and title attributes.
$image_id = get_post_thumbnail_id();    
$image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);  
$image_title = get_the_title($image_id);

但是,当我添加这个 alt='$image_alt' 时,我看到了一个空的 alt。

【问题讨论】:

    标签: php css wordpress alt


    【解决方案1】:
    <img src="whatever-src" alt="'.$image_alt.'">
    

    当它在 echo 中时,这就是你所需要的。 仅当该图像有任何 alt 时。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      相关资源
      最近更新 更多