Domanda

I'm currently designing a theme using Underscores and I want to do something like this with the site's title:

Thisisthetitle

So the title is all one word and the last five characters are different to the rest. I am currently using the bloginfo function to display the title and I can't figure out a way to split it so I can style each section of the title differently.

I have tried creating a function to splice it, but to no avail.

È stato utile?

Soluzione

Figured it out!

function split_title($title) {
$title = get_bloginfo('name');
$word = substr($title, 0 , 5);
$press = substr($title, 5);

$html = "{$word}<span class='bold'>{$press}</span>";

return $html;
}

And then <?php echo split_title($title); ?>

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top