Amit

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; ?>

Last Update on:March 5th, 2023 at 5:19 pm


How to access WordPress functions in external file
Previous post