Support » Plugins and Hacks » show list of current month’s posts (titles only)

  • Resolved 10010110

    (@10010110)


    Hi there, I’m the new guy. 🙂
    I have searched for several hours now, and tried several plugins but none of them really do what I have in mind: I want to display a list of the current month’s posts on my archives page (before the actual monthly archive is displayed).
    Now, I’ve found plugins that would display posts (as on the index page) but I only want the titles of the posts. I’ve tried to use The Loop but that didn’t work.

    Is there any plugin that would suite my needs? Or if not what would I have to modify to make it work? I have only basic knowledge of PHP so I would probably need forever to find it out myself.

    Any help is very much appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • MichaelH

    (@michaelh)

    Unless I’m missing it, couldn’t you just use the template tag, the_title, to display the post title instead of the_content?

    10010110

    (@10010110)

    Yeah, I thought about just copying The Loop from the index page template, putting it in the archives template, and removing the content (effectively just displaying the title) but it didn’t work. It just displayed the title of the archive page (that has the appropriate template applied). However, it still wouldn’t display all posts/titles of the current month only, would it? Also this would lead to problems as “Show at most” is set to 5…? Or am I missing something here and it’s much more simple?

    I need something like recent posts only with a “current month” option.

    MichaelH

    (@michaelh)

    Using the WordPress Default 1.6 theme’s archives.php this code works:

    <h2>Posts for this Month:</h2>
    <?php $current_month = date('m'); ?>
    <?php $current_year = date('Y'); ?>
    <?php query_posts("year=$current_year&monthnum=$current_month&order=DESC"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php  endwhile; ?>
    moshu

    (@moshu)

    archives template

    Here goes your problem!
    archives.php is a Page template
    archive.php is used for monthly archives!

    MichaelH

    (@michaelh)

    I think that will work for either archives.php, if you want to present via a page, or archive.php if you want to present via your archive links.

    10010110

    (@10010110)

    Sweet man! That’s exactly what I was looking for. Thanks a lot for your help. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘show list of current month’s posts (titles only)’ is closed to new replies.