Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active December 5, 2017 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/8f6ed34fe6a172ec2ae30791d72d820d to your computer and use it in GitHub Desktop.
Save billerickson/8f6ed34fe6a172ec2ae30791d72d820d to your computer and use it in GitHub Desktop.
<?php
/**
* Display Posts Shortcode, Use h2 for post title
* @see https://www.billerickson.net/code/dps-use-h2-post-title/
*/
function be_dps_post_title_h2( $output, $original_atts, $image, $title ) {
if( !empty( $original_atts[ 'post_title_as_h2' ] ) && true === filter_var( $original_atts[ 'post_title_as_h2' ], FILTER_VALIDATE_BOOLEAN ) ) {
$new_title = '<h2>' . $title . '</h2>';
$output = str_replace( $title, $new_title, $output );
}
return $output;
}
add_filter( 'display_posts_shortcode_output', 'be_dps_post_title_h2', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment