Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 19, 2011 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/1298344 to your computer and use it in GitHub Desktop.
Save billerickson/1298344 to your computer and use it in GitHub Desktop.
Full Content in Display Posts Shortcode plugin
<?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 ) {
// First check if an excerpt is included by looking at the shortcode $atts
if ( $atts['include_excerpt'] )
// Now let's rebuild the excerpt to be full content
$excerpt = '<div class="listing-content">' . get_the_content() . '</div>';
else $excerpt = '';
// 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;
}
@GaryJones
Copy link

Bill - for reference, the correct order for @param tags is, for example:

@param string $output The original markup for an individual post

Note the removal of the comma after the third argument - the free text / description part doesn't start until after the space after the parameter name.

@billerickson
Copy link
Author

Ah thanks. I'm never sure when writing these docblocks because I've never had a tool that let's me use them

@electricbrick
Copy link

Bill, I'm curious -- is it possible to get shortcode content to render with this snippet? I'm using StudioPress's AgentPress theme + plugin which requries shortcodes to display certain real estate details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment