Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 21, 2011 14:04
Show Gist options
  • Save billerickson/1303939 to your computer and use it in GitHub Desktop.
Save billerickson/1303939 to your computer and use it in GitHub Desktop.
Modify Date Format in Display Posts Shortcode plugin
<?php
/**
* Modify Date Format in Display Posts Shortcode plugin
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
* @link http://wordpress.org/support/topic/plugin-display-posts-shortcode-show-date-in-format-dmy
*
* @param $output string, the original markup for an individual post
* @param $atts array, all the attributes passed to the shortcode
* @param $image string, the image part of the output
* @param $title string, the title part of the output
* @param $date string, the date part of the output
* @param $excerpt string, the excerpt part of the output
* @param $inner_wrapper string, what html element to wrap each post in (default is li)
* @return $output string, the modified markup for an individual post
*/
add_filter( 'display_posts_shortcode_output', 'be_display_posts_date', 10, 7 );
function be_display_posts_date( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
// Change the date
if ( $atts['include_date'] ) $date = ' <span class="date">('. get_the_date('j/n/Y') .')</span>';
else $date = '';
// Now let's rebuild the output.
$output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>';
// Finally we'll return the modified output
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment