WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] show list of current month’s posts (titles only) (7 posts)

  1. 10010110
    Member
    Posted 7 years ago #

    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.

  2. MichaelH
    Member
    Posted 7 years ago #

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

  3. 10010110
    Member
    Posted 7 years ago #

    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.

  4. MichaelH
    Member
    Posted 7 years ago #

    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; ?>
  5. moshu
    Member
    Posted 7 years ago #

    archives template

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

  6. MichaelH
    Member
    Posted 7 years ago #

    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.

  7. 10010110
    Member
    Posted 7 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic