Support » Themes and Templates » Theme Hocks

  • Hey,

    I have the following code in my theme functions.php file…

    add_filter('the_title', 'span_first_word');
    function span_first_word($title) {
    	$words = explode(' ', $title);
    	$words[0] = '<span>'.$words[0].'</span>';
    	$title = implode(' ', $words);
    	return $title;
    }

    What that does is adds <span> around the first word of the title…

    However it adds <span> in the admin list too… but displays the word..
    EG: <span>About</span> Us

    Is there a way to only add <span> if its been displayed on the front of the website?

    Dan

Viewing 1 replies (of 1 total)
  • What is the purpose of adding the span tags? If you want to add style to that word, you can almost certainly do it using CSS with the existing tags or classes or ID’s. Can you post a link to your site and be more specific about what you are trying to do?

Viewing 1 replies (of 1 total)
  • The topic ‘Theme Hocks’ is closed to new replies.