我在一个WordPress站点上工作,该网站有2个块,其中有2个不同类别的预告片。一个块(CAT = 8)显示得很好,但另一个显示不正确的特色图像。
这是包含2个块的页面的代码。我还有2个独立的Pagina来显示帖子,但那里的问题是相同的。
<div style="margin: 0; width: auto;">
<h4 style="border-bottom: 1px solid #444;">Nieuws</h4>
<span class="more-news">
<a href="nieuws">meer nieuwsberichten</a>
</span>
<?php $the_query = new WP_Query( array('showposts' => '2', 'cat' => '9') ); ?>
<?php while ($the_query -> have_posts()) : ?>
<div class="unit-100 group teaser">
<?php if(has_post_thumbnail()){
$id = $the_query->post->ID;
echo get_the_post_thumbnail($id,array(100,100));
$the_query -> the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php the_excerpt(__('(lees meer…)'));
} else {
$the_query -> the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php the_excerpt(__('(lees meer…)'));
} ?>
</div>
<?php endwhile;
wp_reset_postdata();?>
</div>
</div>
<div class="unit-40">
<div class="donate">
<h4 style="border-bottom: 1px solid #444;">Doneer nu!</h4><?php echo do_shortcode('[IDEAL fip_referentie="The Blue Goat Donatie"]'); ?>
</div>
<div class="stories">
<h4 style="border-bottom: 1px solid #444;">Bijzondere verhalen uit Oeganda</h4>
<p><?php echo do_shortcode('[contentblock id=bijzondere-verhalen]'); ?></p>
<?php $the_query2 = new WP_Query( array('showposts' => '1', 'cat' => '8') ); ?>
<div class="">
<?php while ($the_query2 -> have_posts()) :
if(has_post_thumbnail()){
the_post_thumbnail(array(350,350));
$the_query2 -> the_post(); ?>
<span class="story-title"><a href="<?php the_permalink() ?>"><?php
the_title(); ?></a></span>
<?php } else {
$the_query2 -> the_post(); ?>
<a href="<?php the_permalink() ?>">Lees meer....</a>
<?php }
endwhile;
wp_reset_postdata(); ?>
</div>
</div>
1。)确保您的拉动类别ID。在WP仪表板和代码中检查
2。)也许类似的东西:(与此相关的代码,我们可以看到吗?也许在functions.php中?)
<?php $the_query1 = new WP_Query( array('showposts' => '1', 'cat' => '9') ); ?>
<div class="">
<?php while ($the_query1 -> have_posts()) :
if(has_post_thumbnail()){
the_post_thumbnail(array(350,350));
$the_query1 -> the_post(); ?>
<span class="story-title"><a href="<?php the_permalink() ?>"><?php
the_title(); ?></a></span>
<?php } else {
$the_query1 -> the_post(); ?>
<a href="<?php the_permalink() ?>">Lees meer....</a>
<?php }
endwhile;
wp_reset_postdata(); ?>