Created
May 12, 2016 18:00
-
-
Save ronalfy/6987bdb361299ba52b4dfee9dffa6299 to your computer and use it in GitHub Desktop.
Custom H1 for CMB2
This file contains hidden or 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 | |
function nest_custom_title( $post_id = 0, $before = '', $after = '', $echo = true ) { | |
if ( 0 == $post_id ) { | |
$post_id = get_the_ID(); | |
} | |
ob_start(); | |
echo $before; | |
$title = get_post_meta( $post_id, '_custom_h1', true ); | |
if ( false == $title || empty( $title ) ) { | |
echo esc_html( get_the_title( $post_id ) ); | |
} else { | |
echo esc_html( $title ); | |
} | |
echo $after; | |
$title = ob_get_clean(); | |
if ( $echo ) { | |
echo $title; | |
} else { | |
return $title; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment