Jump to content

get date of post and display by monthly


jarvis

Recommended Posts

Hi,

 

I'm using Wordpress but think the priniciple is the same. I wish to get the date of a post for example:

<?php the_time(d M Y') ?>

Once I have the date I then need to list the posts bi-monthly:

Aug - Sept 11

- all posts with a aug - sept date

June - July 11

- all posts with a june - july date

Apr - May 11

Feb - Mar 11

Dec - Jan 11

- all posts with a dec 10 or jan 11 date

Oct - Nov 10

etc

 

Am at a total loss on how to do this? Is anyone able to point me in the right direction?

 

I thought I could get the month and year a post, then use a switch/case statement, problem is, I can't see how I would do the year part and equally the fact that it's dec 10 and jan 11

 

:-(

 

Any help is very much appreciated.

 

Thanks

Link to comment
Share on other sites

Sorry,

Just wondering if this is on the right lines:

<?php
$month = the_time('M');
$year = the_time('Y');

switch (true) {

case ($month == 'Aug' && $year == '2011') : 
	$heading = "Aug - Sept 11";
	break;
case ($month == 'Sept' && $year == '2011') : 
	$heading = "Aug - Sept 11";
	break;		

}
?>

If so, is there a way it can be auto generated? Otherwise I'd need to add a case for all months for the past X years and also cater for all future years?

 

Or is this miles off?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.