我正在使用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>
答案 0 :(得分:0)
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(); ?>