How to Bold First Few Words in Excerpt

The WordPress Excerpt is an optional summary or description of a post; in short, a post summary. It is used to truncate blog posts so that only part of the entry — the introduction or a summary of the post — is displayed, instead of the entire entry.

In my recent project, I need to bold first few words in excerpt. I’ll share the solution here.

Simply put the codes below to your theme’s function.php file

function excerpt_bold($text) {
	$text = explode(' ',get_the_excerpt());
	$text = implode(' ',$text);
	return $text;			

add_filter ('the_excerpt', 'excerpt_bold');

This code will bold first five words. You can change it to other number by replacing ’4′ in the code. But remember, the number should be number of bolded words reduced by one. If You want to bold 8 words, for example, then replace it with 7.

Hope this code snippet helps. :)

Credit :
Thanks to Alchymith and itsalltech1 at

1 Comment to “How to Bold First Few Words in Excerpt”

Add Comments (+)

  1. Tosh says:

    Sorry to bother you, I saw your post on how to group posts by Author and Alphabetically, but I was wondering how I could group them by Date.


  1. 45 Best WordPress Tips and Tutorials of April 2011 |
  2. 45 Best WordPress Tips and Tutorials of April 2011 «
  3. 55 Best WordPress Tricks And Hacks | stylishwebdesigner

Leave a Reply


Amazingly Beautiful WordPress Themes