• I like how posts are archived right away into monthly archives. My question is, at the end of the month, is it possible to have the front page cleared (automatically or manually) to make way for the next month’s posts? Without erasing posts from the archives?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The only way I can think you could do this would be to alter the display options when you come to post at the start of each month.
    Post on the 1st – show only one post
    Make another post – show 2 posts … etc

    Fiddly though, probably not what you are after but WP doesn’t ‘clear the decks’ at all (yet …..)

    Would it be possible to alter the code on the front/index page to only get posts for the current month? Not sure what the actual code for that would look like, but it would end up “wiping” the page at the beginning of the month.

    Thread Starter jeffreyt

    (@jeffreyt)

    I’m going to try to figure something out. Let me know if you find something.

    I’m also interested in this. Please update us if you come up with a way of doing it.

    Find the part in your code where it says

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Just under that (i.e., the next line) add:

    <?php if(is_home) { if(get_the_time('n') != date('n')) { break; } } ?>

    What it does is, inside the loop, it says:

    If this is the front page,
    If the current post’s month is not equal to the current month on the server,
    Exit the loop.

    There are probably many other ways to do the same thing, and probably more elegant, but this is easy to copy/paste ??

    sorry, it’s

    <?php if(is_home()) { if(get_the_time('n') != date('n')) { break; } } ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘End of month front page clearing. Possible?’ is closed to new replies.