Title: Theme Hocks
Last modified: August 20, 2016

---

# Theme Hocks

 *  [Danny159](https://wordpress.org/support/users/danny159/)
 * (@danny159)
 * [14 years ago](https://wordpress.org/support/topic/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)

 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [14 years ago](https://wordpress.org/support/topic/theme-hocks/#post-2766309)
 * 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.

 * 1 reply
 * 2 participants
 * Last reply from: [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/theme-hocks/#post-2766309)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
