I'm trying to use a function that adds a "span" around the first word of every post title in a Wordpress site, and found this extremely similar question. The function in the second answer works fine when there's a link inside the H2 element.
But In my site, I'm not using the post title as a link, so the found solution doesn't work. I've tried to come up with a new preg-replace pattern, as to skip the detection of the link part, but haven't been able to get it.
Basically, I want this:
<h2><?php the_title(); ?></h2> or <h2>Converted post title</h2>
... to become this:
<h2><span>Converted</span> post title</h2>
No comments:
Post a Comment