因此,在我为客户机制作的这个主题中,自定义程序中有一个部分,允许他们更改每个页面上的标题,我的问题是如何获取该图像的alt标记?
图像通过媒体库上载,因此在上载图像后设置了alt文本。
下面是我尝试获取图像alt标记的内容
$img_id = get_post_thumbnail_id(get_the_ID());
$alt_text = get_post_meta($img_id , \'_wp_attachment_image_alt\', true);
<img src="<?php echo get_theme_mod(\'about-header\', get_stylesheet_directory_uri() . \'/assests/imgs/placeholder.png\'); ?>" alt="<?php echo $alt_text; ?>">
 出于某种原因,它似乎没有得到图片alt标签,我不明白为什么
自定义程序的代码(以防我必须在其中执行某些操作)
$wp_customize->add_section(\'page_header\', array(
    \'title\'         => __(\'Page Headers\', \'bissell-theme\'),
    \'priority\'      => 30,
    \'description\'   => __(\'Below are the options to change your header images for all your pages. Just simply click \\\'Select Image\\\' and choose a Image from the Media Libary or Upload one your self\'),
));
$wp_customize->add_setting(\'about-header\');
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, \'about_header_control\', array(
    \'label\'         => __(\'About Us - Header\'),
    \'section\'       => \'page_header\',
    \'settings\'      => \'about-header\',
)));