现在花了一段时间,几乎没有任何帮助。
我正在尝试更改循环,以便它检查每篇文章是否有特色图像,如果找到一个,它会显示该图像而不是截断的文章和链接。
所以基本上(在逻辑上)
Check for featured image
if there is a featured image display the featured image (and nothing else).
else display a truncated version of the article.
有人可以帮忙吗?
你去吧;
<?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?>
<?php $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array( 960,960 )); ?>
<img src="<?php echo $img_src[0]; ?>" alt="My image" />
<?php } else { ?>
<?php the_excerpt(); ?>
<?php } ?>
有关详细信息,请查看法典中的以下内容;
WordPress 特色图片
WordPress摘录