WordPress.org

Ready to get started?Download WordPress

Forums

Grouping Post Links by Month (1 post)

  1. bekabug
    Member
    Posted 6 years ago #

    Using WP 2.3.3

    In my category.php file I have this section which gets the category of my choosing and shows all the posts as a link.

    I have the_time in here but it's in the wrong spot as it's posted here. If I move it into the foreach loop it prints the month above every link which wasn't exactly what I was after.

    Any thoughts on how I would (if possible) ask WordPress to print the month and year only once?

    <ul>
                 <div><?php the_time('F Y'); ?></div>
                <?php
                global $post;
                $myposts = get_posts('numberposts=5&order=DESC&orderby=post_date&category=41');
                foreach($myposts as $post) :
                ?>
    
                    <li><a href="<?php the_permalink(); ?>/" target="_blank"><?php the_time('j F Y'); ?> &ndash; <?php the_title(); ?></a></li>
    
                <?php endforeach; ?>
                <li><a href="#">Browse All</a></li>
                </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.