Retrieve and Show Date from previous/next posts (WordPress)

I wrote a short script for a friends website, where he wants to show the last posts date and datelink. There were no framework based function included, therefore i had to set up following snippet.

if(get_post_type( $post ) == 'post'){
	$previous = true;
	$in_same_cat = false;
	$excluded_categories = '';
	//retrieves the prev or next post if last value is true/false
	$adjacent_post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous );
	//Name of German Month
	$germanMonthName = array("",  
	$mYear = mysql2date("Y", $adjacent_post->post_date);
	$mMonth = mysql2date("n", $adjacent_post->post_date);
		$mMonthGER = $germanMonthName[$mMonth];
	$mDay = mysql2date("j", $adjacent_post->post_date); 
	$dateLink = $mDay. ".". $mMonthGER . ".". $mYear;
	previous_post_link('%link',$dateLink , $in_same_cat, $excluded_categories );

No Comments

Add Comment