WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my site: www.finmand.dk/almastofa/nyheder (a danish site) I have used this code to navigate between the post:

<?php foreach(get_the_category() as $category)
{ $thecat = $category->cat_ID; } ?>
<?php $result = "<ul class='lcp_catlist'>";
$catposts = get_posts('category='.$thecat."&orderby=monthly=asc&numberposts=".$NUMBEROFPOSTS);
foreach($catposts as $single):
    $result .= "<li><a href='";
    $result .=get_permalink($single->ID)."'>".$single->post_title."</a></li>";
$result .= "</ul>";
echo $result; ?>

This right thing about the code is that it only shows on the News page /Nyheder.

Problem is It only shows the newest post, and links to a page called sample-post. Which I don't have, so I get page not found. I would like it to link to page.php or single.php. But I can't figure out where to change it in the code. And I would like the navigation in the sidebar to be shown by Month and year posted. Not as now with name. But again - Beginner programmer with zero luck. So can anybody give me a hint on what to write?

I know I may be playing with the big boys now regarding knowledge about "heavy" programming, and my problem may seem insignificant - but we all have to start somewhere. Hopeful Thanks Marlene

share|improve this question

If you're trying to navigate between posts in the same category, would next_post_link()/previous_post_link() work for you?

These functions have an $in_same_cat argument, that would appear to suit your needs?


Here is a Plugin, WP Category Archives, that might point you in the right direction? It purports to display:

...a monthly or yearly archive of posts for one specific category. It is very similar to the WordPress Archive except that it just displays one specific category's posts, not all categories. It can be configured to either show a listing or a pulldown by month or year with or without post counts.

share|improve this answer
I don't think so, I need a numbered organized list of post: May 2010. June 2010 and so on to appear on the sidebar. So guest can chose which one to see. – user4378 Apr 1 '11 at 23:11
I found a Plugin that might suit your needs (or provide example code. See my edited answer. – Chip Bennett Apr 1 '11 at 23:25
Mhmm it would appear my theme is not made with widgets in mind (damm). Shall I find a theme with widgets in it, and then change everything? – user4378 Apr 1 '11 at 23:41
That, or just incorporate the code stand-alone in your current Theme. – Chip Bennett Apr 1 '11 at 23:52
Oh you wonderful man you, it is almost there now. But it shows all the post. I would like it to show the post that matches the month, and only that. And perhaps that the first post you see is always the newest. - And now it shows on the other pages as well, I would like it to be only on the news page – user4378 Apr 2 '11 at 0:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.