Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 11, 2013 15:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/4511408 to your computer and use it in GitHub Desktop.
Save billerickson/4511408 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'display_posts_shortcode_output', 'be_display_posts_hide_title', 10, 9 );
/**
* Display Post Shortcode, Hide Title
* Disable title with [display-posts include_title="false"]
*
* @author Bill Erickson
* @link http://wordpress.org/support/topic/how-to-supress-the-title?replies=1#post-3673938
*
* @param string $output
* @param array $original_atts
* @param string $image
* @param string $title
* @param string $date
* @param string $excerpt
* @param string $inner_wrapper
* @param string $content
* @param array $class
* @return string output
*/
function be_display_posts_hide_title( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class ) {
if( isset( $original_atts['include_title'] ) && "false" == $original_atts['include_title'] ) {
$title = '';
if ( !empty( $excerpt ) )
$excerpt = '<span class="excerpt">' . get_the_excerpt() . '</span>';
$output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $excerpt . $content . '</' . $inner_wrapper . '>';
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment