Skip to content

Instantly share code, notes, and snippets.

@caralgar
Created October 14, 2015 07:23
Show Gist options
  • Save caralgar/5b1eaab8c74215b7b349 to your computer and use it in GitHub Desktop.
Save caralgar/5b1eaab8c74215b7b349 to your computer and use it in GitHub Desktop.
Bold first word jquery in WordPress
<?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