开发者

Wordpress archive page with month following by posts + date

I am trying to have an archive section in a template with a certain layout.

I am trying to get a list as follows:

FEBRUARI
01-02-2011 - Title 3
03-02-2011 - Title 4

JANUARY
01-01-2011 - Title
03-01-2011 - Title 2

< older entries     newer entries>`

I am trying to get my code to work, but it fails and only shows one post per month.

<?php
// List Pages by Month/Day
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'paged' => $paged,
 'post_type' => 'post',
 'posts_per_page' => 10,
             );
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
  $this_dt = get_the_time('M',$post->post_date);
  if ($curr_dt != $this_dt) { ?>
<h4><?php echo $this_dt; ?></h4>
  <ul class="artikelen">
  <li><a href="<?php the_permalink(); ?>"><span><?php echo get_the_time('d');?> - <?php echo get_the_time('M');?> | <?php echo get_the_time('Y'); ?> |</span><?php the_title();?></a></li><?php echo "</ul>"; }
 $curr_dt = $this_dt; endwhile; ?>
<div class="navigation">
  <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
  <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>
<?php else :
// Code here for no pages found
endif;
?>

I would like t开发者_如何学Goo know what i am doing wrong or whether its possible at all. Thanks!


The IF loop is only used to display The Month once, close it rightc after displaying the month:

<?php
// List Pages by Month/Day
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'paged' => $paged,
 'post_type' => 'post',
 'posts_per_page' => 10,
             );
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
  $this_dt = get_the_time('M',$post->post_date);
  if ($curr_dt != $this_dt) { ?>

<h4><?php echo $this_dt; ?></h4>

   <?php } ?>

  <ul class="artikelen">
  <li><a href="<?php the_permalink(); ?>"><span><?php echo get_the_time('d');?> - <?php echo get_the_time('M');?> | <?php echo get_the_time('Y'); ?> |</span><?php the_title();?></a></li><?php echo "</ul>"; 
 $curr_dt = $this_dt; endwhile; ?>
<div class="navigation">
  <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
  <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>
<?php else :
// Code here for no pages found
endif;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜