I’m using the following custom query in WordPress within a for-loop that enables me to create a tabbed archive for the previous 8 months of the custom post type I’ve created for ‘news’.
This works perfectly however I wish to then show every older post under the heading ‘Older news. I’m struggling to figure out how to separate the posts that are older than 8 months from the current date at any one time.
Can anyone advise me as to a custom query structure that would enable me to do this.
Here’s the code i use to output the CPTs in their relevant containers.
<?php for($i = $this_month-1; $i > $this_month-8; $i--) :
if($i==-1){$m=11;}
if($i==-2){$m=10;}
if($i==-3){$m=9;}
if($i==-4){$m=8;}
if($i==-5){$m=7;}
if($i==-6){$m=6;}
if($i==-7){$m=5;}
if($i==-8){$m=4;}
else{$m=$i;}
query_posts( array(
'post_type' => 'news',
'posts_per_page' => '-1',
'orderby' => 'date',
'order' => 'ASC',
'monthnum'=>$m
) );
.......
You may try this
Update: May be this can help you.