【发布时间】:2012-09-15 10:54:35
【问题描述】:
我在 211 的 index.php 文件中使用下面的代码
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”生成的图像缩略图上尺寸。 问题是首页只显示帖子的标题和缩略图,只显示第一个帖子。
您可以在这里查看网站:http://fusion.fusionconstruction.co.uk/
选择类别 ID 4 的其他帖子的链接:
http://fusion.fusionconstruction.co.uk/fusion-media-at-revolution-round-1/
http://fusion.fusionconstruction.co.uk/fusion-launch-new-website-for-dean-downing/
我想显示所有与第一个类似的帖子。
谢谢!
【问题讨论】:
-
对不起,我对正在发生的事情和未发生的事情感到困惑。我只看到第一个链接上列出了 1 个帖子,其他 2 个链接看起来一样。什么是对的,什么是错的?
-
啊,等等,好的,第一个链接上应该有 3 张图片?前两个的链接是空的,是吗?这些文章是否有特色图片,或者图片只是插入到页面中?
-
@zenkaty - 是的,你没看错。这只是所有帖子上的插入图像。没有推荐。
标签: php css wordpress loops content-management-system