I need to add a span
tag to an h1
heading in wordpress. I tried writing in through the CMS but it renders the span
tag as text.
The site’s title is a name and I want to give different styles to the words.
Suggestions?
Following David Thomas‘s advice I’ve written this: but it appends the span
last and empty.
<h1>
<a href="<?php bloginfo('url'); ?>/">
<?php
$completeName = bloginfo('name');
$split = explode(" ",$completeName);
echo $split[0]."<span>".$split[1]."</span>"
?>
</a>
</h1>
You should be using
get_bloginfo
as Felipe suggested, but still pass in the ‘name’ parameter.I was just working on the same code for the same reason and thought I should post for future visitors:
Apply the style to the
h1
instead.By the way, you probably want to edit the theme.
What about:
Can’t test it for now, but here’s the documentation about it: