Finally I have decided to add span tags around the first word of titles while working on wordpress theme and after searching a lot, I found “free-php.net” which contains the solution of my quires. So, below are the codes which you have to copy paste at functions.php file.
Note: “$” use for declaration of variables
“echo” use to display content
function arixWP_title() { global $post; $title = '<h2><a href="' . get_permalink() . '" title="' . get_the_title() . '" rel="bookmark">' . get_the_title() . '</a></h2>'; $title = preg_replace('/<a([^>]+)>([A-z0-9_]+)\s/i', '<a$1><span>$2</span> ', $title); echo $title; } |
Wherever you would like introduce your functions.php file then just paste the following code:
<?php arixWP_title(); ?> |
Comments