【发布时间】:2015-02-26 10:40:50
【问题描述】:
我已经完成了一个自定义 wordpress 主题,但现在无法找到最初的人。
所有类别都显示在所有类别页面上,尽管我创建了一个新类别并将 2 个帖子移入其中。 (只是试图创建一个档案)
请各位好心人指出我需要在 category.php 页面中寻找的方向吗? (见下文)
<?php if ( is_day() ) : ?>
<h1 class="page-title"><?php printf( __( 'Daily Archives: <span>%s</span>', 'your-theme' ), get_the_time(get_option('date_format')) ) ?></h1>
<?php elseif ( is_month() ) : ?>
<h1 class="page-title"><?php printf( __( 'Monthly Archives:<span>
<?php $archive_query = new WP_Query('showposts=1000');
while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
<div class="row">
<div class="span3">
<?php the_post_thumbnail('full');?>
</div>
<div class="span5">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="entry-summary">
<?php the_content( __( 'Continue reading <span class="meta-nav">
</div><!-- .entry-summary -->
</div><!-- #post-<?php the_ID(); ?> -->
</div>
</div>
<?php endwhile; ?>
我不得不删除一些代码,因为它不会让我过去,这并没有让我充满信心。
我不是 Wordpress 爱好者,但知道基础知识(我认为)
提前致谢
【问题讨论】:
-
这是您的代码所期望的。切勿在存档页面上使用自定义查询。改用
pre_get_posts更改主查询。 -
我认为这将是开始的部分
-
正确:-)。请记住也要从循环中删除
$archive_query->部分 -
那会是正确的吗? have_posts()) : $pre_get_posts->the_post(); ?>
-
它仍然显示所有帖子?抱歉,我似乎知道的比我想的要少得多
标签: php wordpress categories