Timeline for Adding span tags to post titles using regex
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 8, 2020 at 1:45 | vote | accept | HopefullCoder | ||
Jul 7, 2020 at 15:38 | answer | added | Tom J Nowell♦ | timeline score: 1 | |
Jul 7, 2020 at 15:30 | comment | added | Tom J Nowell♦ |
You don't need regex, just split the string by the : character and wrap the array items in span tags. A regular expression is just overcomplicating it ( and you shouldn't parse HTML with regex anyway )
|
|
Jul 7, 2020 at 15:16 | answer | added | mozboz | timeline score: 1 | |
Jul 7, 2020 at 15:11 | comment | added | mozboz | so do you need to allow for the case with no colon? what should happen then? why not just add that case to your first piece of code if it's working ;-) | |
Jul 7, 2020 at 15:04 | comment | added | Ivan Shatsky |
If you want the_title() function to return its result instead of echoing it, you should use $string = the_title( '<h1 class="entry-title test">', '</h1>', false );
|
|
Jul 7, 2020 at 14:50 | history | asked | HopefullCoder | CC BY-SA 4.0 |