Skip to content

Instantly share code, notes, and snippets.

@cheh
Created October 6, 2017 12:12
Show Gist options
  • Save cheh/adeb7ee05cd7520d94e7f6094c819a8e to your computer and use it in GitHub Desktop.
Save cheh/adeb7ee05cd7520d94e7f6094c819a8e to your computer and use it in GitHub Desktop.
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