Split off part of the_content() to style?
I cant use the_excerpt, because I need to grab the first, say 5 words, of the_content and style it differently.. but only on the first p开发者_运维百科ost on the page. Is there a way to do this? Thanks!
Oh wow twitter came through ;) Apparently there is a function to grab the content without it echoing out, so here is the link if anyone else stumbles on this. http://codex.wordpress.org/Function_Reference/get_the_content
I pretty sure you can write a filter function in functions.php that manipulates the excerpt or content what ever way you want.
Yes, there is a filter for that.
function my_content_filter($the_content) {
// fiddle with the content here
// we only want to run once, so remove yourself right away
remove_filter('the_content', 'my_content_filter', 10);
return $the_content;
}
add_filter('the_content', 'my_content_filter', 10);
Use the is_home()
function to do the appropriate checks if you only want this to run on the home page.
精彩评论