Created
October 14, 2015 07:23
-
-
Save caralgar/5b1eaab8c74215b7b349 to your computer and use it in GitHub Desktop.
Bold first word jquery in WordPress
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 | |
function bold_first_word() { | |
$out = " | |
<script type=\"text/javascript\"> | |
jQuery('#content h1').html(function(i,html){ | |
return html.replace(/^\s*([^\s]+)(\s|$)/, '<span class=\"first-word\">$1 </span>'); | |
}); | |
</script> | |
"; | |
echo $out; | |
} | |
add_action( 'wp_footer', 'bold_first_word', 1); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment