WordPress.org

Support

Support » Plugins and Hacks » Display Posts Shortcode » [Resolved] [Plugin: Display Posts Shortcode] show date in format: D/M/Y

[Resolved] [Plugin: Display Posts Shortcode] show date in format: D/M/Y

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bill Erickson

    @billerickson

    You’ll need to use the output filter to modify the date, as the format is not editable through the shortcode. Something like this would go in your functions.php file:

    https://gist.github.com/1303939

    More info on date formats

    Bill, this is a great plug-in! There was a small error in your filter code, which i have updated below.

    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;
    }
    Plugin Author Bill Erickson

    @billerickson

    Good catch! Yeah, this code was untested so I just copied the date part directly out of the plugin. Since the attributes haven’t been parsed yet, your approach is needed. I’ve updated the code.

    Another approach would be to check if( !empty( $date ) )

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Display Posts Shortcode] show date in format: D/M/Y’ is closed to new replies.
Skip to toolbar