WordPress.org

Ready to get started?Download WordPress

Forums

How to display current month and three posts from previous month? (2 posts)

  1. myownalias
    Member
    Posted 3 years ago #

    What I am looking to do is display all entries minus one category from the current month (which I already have code in place for)+ three entries from the previous month. I want to be able to do this because I sometimes don't post for a few days and would like to not have a blank home page because I don't post until the 3rd or 4th of the month! I currently have the below snippet for showing he current month only and excluding the one category as described above!

    $current_month = date('m');
    $current_year = date('Y');
    query_posts("cat=-1545&year=$current_year&monthnum=$current_month&order=DESC");

    Any help would be appreciated!

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    this might help:

    $last_month = date("F", strtotime("-1 month"));
    $last_year = date("Y", strtotime("-1 month")); //in case of january

    http://php.net/manual/en/function.date.php

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.