secret
Last active

  • Download Gist
functions.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php
/**
* Full Content in Display Posts Shortcode plugin
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
*
* @param string $output the original markup for an individual post
* @param array $atts all the attributes passed to the shortcode
* @param string $image the image part of the output
* @param string $title the title part of the output
* @param string $date the date part of the output
* @param string $excerpt the excerpt part of the output
* @param string $inner_wrapper what html element to wrap each post in (default is li)
* @return string $output the modified markup for an individual post
*/
add_filter( 'display_posts_shortcode_output', 'be_display_posts_full_content', 10, 7 );
function be_display_posts_full_content( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
 
// See if 'full_content' is set in shortcode.
// Ex: [display-posts full_content="true"]
if ( isset( $atts['full_content'] ) && "true" == $atts['full_content'] )
$excerpt = '<div class="listing-content">' . get_the_content() . '</div>';
 
// Now let's rebuild the output. Only the excerpt changed so we're using the original $image, $title, and $date
$output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>';
 
// Finally we'll return the modified output
return $output;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.