A few weeks back (actually 18 days), @karelgeenen asked me on Twitter how he could bold the text above the <!--more--> tag in WordPress, like the Dutch site Marketingfacts (which is actually built in Expression Engine).
I didn't know back then and this afternoon I decided to try and solve it for him. It turned out to be quite simple. I've made it into a simple plugin, called Yoast Style Intro, but you can also just add the code below to your themes functions.php.
The plugin wraps the intro in a span with class="yoast_intro", so you can style it by adding, for instance, the following code to your themes style.css:
.yoast_intro { font-weight: bold; }
The code
Add this to your themes functions.php:
function yoast_style_intro($content) { if (is_single() || is_page()) { $content = '<span class="yoast_intro">'.$content; $content = str_replace('<span id="more','</span><span id="more',$content); return $content; } } add_filter('the_content','yoast_style_intro',1,1);
Or you can download the plugin here.
Be aware that if you use the filter the_content multiple times on a page, this plugin might give you trouble.






Smart and easy solution for a question I also had, but wasn't able to solve myself :-)
Have a great Xmass!
Simple but elegant solution, thanks for this :)
Looks pretty cool... could you use a static variable inside the yoast_style_intro() function to prevent problems when the_content is called multiple times?
Great information!
I have been looking for a way to do this (got here by google).
Very simple solution to an annoying little problem, thanks :)
thx for ur info.. :)
Its a very simple tip but very effective. Thanks for the tip.
On my blog I use a simple CSS pseudo class selector to accomplish the same effect:
body.single div.entry-content p:first-child {font-weight:bold;}No need to edit php-files or add HTML-elements... Except when you also want bold text in IE6.
Thanks for sharing!
This does not seem to work on my blog. On the main page, no content appears under the headlines.
Yet on the full view, it appears as it normally should.
being a novice in blogging, what could be the best possible benefits from making the intro part bold? just curious.. who knows i might use it. thanks!