我正在尝试获取页面的特色图像 alt 并将其作为段落文本回显,但我的代码似乎不起作用。
我目前能够回显图像并且它运行良好。
这是我正在使用的代码:
<?php
get_header(); ?>
</div>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="header-image">
<?php echo get_the_post_thumbnail($page->ID, 'full'); ?>
<?php $alt = get_post_meta( $attachment_img->ID, '_wp_attachment_image_alt', true ); ?>
<p><?php echo $alt; ?></p>
</div>