Wordpress文章缩略图问题(首页上只有1个缩略图) [英] Wordpress Post Thumbnail Issue (Only 1 thumbnail on frontpage)
问题描述
我使用twentyeleven的index.php文件下面的代码
I'm using the below code on index.php file of twentyeleven
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="post-thumb-title">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(632,305));?></a>
<p class="thumb-title"><?php the_title(); ?></p>
</div>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
从上面的代码可以看到,我只显示Cat ID = 4并且我使用CSS来覆盖图像缩略图上的标题,该缩略图是使用具有自定义大小的函数the_post_thumbnail生成的。
问题是,首页只显示第一篇文章的标题和缩略图。
As you can see from the code above, I'm only showing the posts with Cat ID = 4 and I'm using css to overlay the title on the image thumbnail which is generated using the function "the_post_thumbnail" with a custom size. The issue is that the frontpage is only showing the title of the posts and thumbnail only for the 1st post.
您可以在这里看到网站: http://fusion.fusionconstruction.co.uk/
You can see the website here: http://fusion.fusionconstruction.co.uk/
指向类别ID 4的其他帖子的链接:
Links to other posts with category ID 4 selected:
http://fusion.fusionconstruction.co.uk/fusion-media-at-revolution-round-1/
http:// fusion .fusionconstruction.co.uk / fusion-launch-new-website-for-dean-downing /
我想显示所有类似的帖子第一个。
I would like to display all the posts similar to the 1st one.
谢谢!
推荐答案
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
应该
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
也就是说,不应该对&符号进行urlencode。
That is, you shouldn't urlencode the ampersand. Hopefully this is what is messing up your query.
此外, the_post_thumbnail()
会显示帖子的精选图片,所以为了产生一个缩略图,你需要确保所有的帖子都有一个精选的图片。
Also, the_post_thumbnail()
will show the post's featured image, so for it to produce a thumbnail you need to make sure that all the posts have a featured image.
这篇关于Wordpress文章缩略图问题(首页上只有1个缩略图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!