【发布时间】:2014-07-23 20:16:38
【问题描述】:
我正在将SuperSimple 主题用于wordpress 博客,并尝试自定义category.php 页面。我想在所有旧帖子的较小网格之上为每个类别中的最新帖子制作大图像。
到目前为止,我已经按照我想要的方式工作了,除了顶部图像 (div id="post1") 只是总体上最新的帖子,而不是该类别的最新帖子。这是类别页面之一:http://meanmargie.com/category/hospitality/
这是我的代码:
<header class="header">
<h1 class="entry-title"><?php single_cat_title(); ?></h1>
<?php if ( '' != category_description() ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . category_description() . '</div>' ); ?>
</header>
<div id="post1">
<?php query_posts('showposts=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?><?php if ( has_post_thumbnail() ) { the_post_thumbnail('featured'); } ?>
<div id="post-info"><a href="<?php the_permalink(); ?>"title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a><br><a href="<?php echo get_permalink(); ?>"> Read More</a></div>
<?php endwhile; endif; wp_reset_query();?>
</div>
<br>
<div id="post2">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?><?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium'); } ?>
<div id="post-info"><a href="<?php the_permalink(); ?>"title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a><br><a href="<?php echo get_permalink(); ?>"> Read More</a></div>
<?php endwhile; endif; ?>
</div>
【问题讨论】:
标签: php wordpress categories