我似乎在尝试显示特色图像的“可选文本”时遇到了问题。
这是我一直在研究的代码。不确定为什么备选文本显示为空白。
<?php
$projects = new WP_Query( array( \'post_type\' => \'print-billboard\' ) );
if ( $projects->have_posts() ) : while ( $projects->have_posts() ) :
$projects->the_post();
?>
<?php
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), \'large\' );
$featured_image_url = wp_get_attachment_url( get_post_thumbnail_id() );
$alt = get_post_meta( $featured_image, \'_wp_attachment_image_alt\', true );
if ( has_post_thumbnail() ) :
?>
<a href="<?php echo $featured_image_url; ?>" id="post-<?php the_ID(); ?>" <?php post_class( \'four columns project-post fancybox\' ) ?> >
<?php $thumbnail_meta = get_post_meta( $featured_image, \'_wp_attachment_image_alt\', true ); ?>
<figure class="full-width featured-image">
<img src="<?php echo $featured_image[0]; ?>" data-fancybox-group="gallery" title="Lorem ipsum dolor sit amet" alt="<?php echo $featured_image; ?>" />
<div class="overlay">
</div>
</figure>
</a>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php endwhile; else: ?>
<p class="error-message">No Projects</p>
<?php endif; ?>
<?php wp_reset_query(); ?>