Last active
August 29, 2015 14:11
-
-
Save pelmered/76830d0b283a09548bfb to your computer and use it in GitHub Desktop.
Color of first word in WordPress content
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
add_filter('the_content', 'set_first_word_color', 10); | |
function set_first_word_color( $content ) | |
{ | |
$color = '#FF0000'; | |
$pos = strpos(ltrim($content), ' '); | |
$new_content = '<span style="color: '.$color.'"'.substr($content, 0, $pos).'</span>'.substr($content, $pos); | |
return $new_content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment