我正在使用带有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。
发布于 2019-12-25 09:49:54
<img src="whatever-src" alt="'.$image_alt.'">这就是你需要的,当它在echo里面的时候。仅当存在与该图像相关联的alt时。
https://stackoverflow.com/questions/59473891
复制相似问题