• Resolved csleh

    (@csleh)


    I”ve been trying various methods of adding the year to this function, but I keep breaking the page. How can I sort by just the current year?

    <?php
    	global $post;
    	$categories = get_the_category();
    	$category = $categories[0];
    	$cat_ID = $category->cat_ID;
    	$myposts = get_posts("numberposts=20&category=$cat_ID");
    	?>
    	<?php foreach($myposts as $post) :?>
    	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	<?php endforeach; ?>

    After this list I’ll (try to) add a link to archives for posts in this category by year.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add the year to this function’ is closed to new replies.