How to add span on WordPress Title for second word.

If you want to add two different color in your the title tag. you can use below code.

<?php $words = explode(' ', the_title('', '',  false)); $words[1] = '<span>'.$words[1].'</span>'; $title = implode(' ', $words); echo $title; ?>

Leave a Reply

Your email address will not be published.