Created
January 11, 2017 21:34
-
-
Save troutacular/4b6e04e2641e3fc23042e768d858ba95 to your computer and use it in GitHub Desktop.
Javascript: Site Acronym for 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
// wrap the first word of the site title matching 'string' in a span to apply highlight color | |
function siteAcronymClass(acronym) { | |
var strTitle = document.getElementsByClassName('site-title')[0].innerHTML; | |
var newStrTitle = strTitle.replace(acronym, '<span class="site-acronym">' + acronym + '</span>'); | |
if ( strTitle !== null ) { | |
document.getElementsByClassName('site-branding-title')[0].innerHTML = newStrTitle; | |
} | |
} | |
// Replace string value with acronym you want to wrap with a span class. | |
siteAcronymClass('Acronym'); | |
// end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment