Created
October 6, 2017 12:12
-
-
Save cheh/adeb7ee05cd7520d94e7f6094c819a8e 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
add_filter( 'the_content', 'prefix_change_hello_to_morning' ); | |
function prefix_change_hello_to_morning( $content ) { | |
if ( is_admin() ) { | |
return $content; | |
} | |
$post_id = get_the_ID(); | |
$post_type = get_post_type( $post_id ); | |
if ( ! in_array( $post_type, array( 'post', 'page' ) ) ) { | |
return $content; | |
} | |
$current_time = current_time( 'timestamp' ); | |
if ( $current_time > strtotime( '12:00am' ) && $current_time < strtotime( '12:00pm' ) ) { | |
return str_replace( 'Hello', 'Good Morning', $content ); | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment