Return to Snippet

Revision: 49950
at August 3, 2011 02:00 by cpres


Initial Code
<?php
$curyear = date("Y");
$curdate = array();
$totalmonths = 24;

for ( $i=0; $i<$totalmonths; $i++ ) {
	$newmonth = date("m",strtotime("-$i Months"));

	if ($newmonth == '12' && date("m") != '12')
		$curyear = $curyear-1;
		
	$curdate[$i] = array("mnum" => $newmonth, "ynum" => $curyear);
}

$output = "
<?xml version=\"1.0\">
<blocks>
<block title=\"Article Archive\">
	<links>
            ";
for ( $i=0; $i<$totalmonths; $i++ )
{
	$output .= "<link target=\"http://www.outdoorresearchverticulture.com/{$curdate[$i]['ynum']}/".$curdate[$i]['mnum']."/?ec3_listing=disable\">". strftime("%B, %Y",strtotime($curdate[$i]['mnum']."/1/".$curdate[$i]['ynum']))." </link>	
		";
}
		

$output .= "
	</links>
</block>
</blocks>";
header("Content-Type: application/rss+xml");
echo $output;

?>

Initial URL


Initial Description
In case you need to create your own listing of the last # of trailing months of Archived Wordpress Articles. This one is being used to pull the info onto a Magento page.

Initial Title
XML Feed - Monthly Archives of Wordpress Articles

Initial Tags
date, wordpress, xml

Initial Language
PHP