2011-05-18 67 views
0

我想在具有一定佈局的模板中有檔案部分。WordPress的檔案頁與月以下的帖子+日期

我試圖獲取列表如下:

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>` 

我試圖讓我的代碼工作,但它失敗,只顯示每月一個職位。

<?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; 
?> 

我想知道我做錯了什麼或者它是否可能。謝謝!

回答

1

中頻環僅用於顯示的每月一次,關閉它rightc顯示一個月後:

<?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

我完全忘了回覆當時的情況。這工作像一個魅力,感謝您的努力! – Ewald 2011-07-25 17:32:53

相關問題