-
-
Save billerickson/8f6ed34fe6a172ec2ae30791d72d820d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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