【发布时间】:2021-03-26 06:43:37
【问题描述】:
在处理 WordPress 主题问题时,我有一个存档页面,顶部有一个特色帖子,其中显示了特色图片、发布日期和摘录以及下面的其他帖子。
遇到了一个问题,其中精选帖子的标题正确,图片正确,但摘录不正确。它会引入不同的帖子文本。
关于下面的代码有什么不正确的任何线索吗?
<?php
$args = array(
'numberposts' => '1' ,
'post_type' => 'post',
'meta_key' => 'post_featured',
'meta_compare' => '=',
'meta_value' => 1
);
$recent_posts = wp_get_recent_posts( $args );
$fID = 0;
foreach( $recent_posts as $recent ) : ?>
<?php $fID = $recent["ID"]; ?>
<div class="blog-listing featured_post">
<a class="blog-image-lg" href="<?php echo get_permalink($recent["ID"]); ?>" style="background-image: url('<?php echo get_the_post_thumbnail_url( $recent["ID"], 'full' ); ?>');">
<span>FEATURED POST</span>
<?php echo get_the_post_thumbnail( $recent["ID"], 'post-thumbnails-big' ); ?>
</a>
<div class="blog-info pull-left">
<a href="<?php echo get_permalink($recent["ID"]); ?>"><h3 class="blog-title"><?php echo $recent["post_title"]; ?></h3></a>
<span class="blog-date"><?php echo strtoupper(get_the_date('F j, Y')); ?></span>
<p><? echo the_excerpt(); ?></p>
<p class="readmore-wrapper"><a class="readmore" href="<?php echo get_permalink($recent["ID"]); ?>">READ MORE »</a></p>
</div>
</div>
【问题讨论】:
标签: php wordpress wordpress-theming