Saturday, May 19, 2012

Customize Wordpress 2.9 excerpts

Posted by admin On April - 18 - 2010

In WordPress themes, you would see the homepage displaying blocks of post excerpts. These excerpts are generated using the template tag

<?php the_excerpt(); ?>

By default this template tag returns the first 55 words of the post’s content. This teaser is generated only if you have not specified any custom excerpt from your post editor section. But what if you want to display more than 55 words on your excerpts? Simple, just add the following code to your theme function.php file. It will return first 100 words of post’s content.

function new_excerpt_length($length) {

return 100;

}

add_filter(‘excerpt_length’, ‘new_excerpt_length’);

What about the [...] string at the end of excerpt
By default WordPress excerpts shows a [...] string at the end of the excerpt. what if you want to change this to a link. something like [Read More] which links to full post view.To do that just add the following code to your functions.php file.

function new_excerpt_more($more) {

return ‘<a href=”‘. get_permalink($post->ID) . ‘”>’ . ‘ [Read More]‘ . ‘</a>’;

}

add_filter(‘excerpt_more’, ‘new_excerpt_more’);

Reference: WordPress Codex

Popularity: 4% [?]

Leave a Reply

improve your SEO potential

For most people the upcoming holiday season will be one for relaxing and spending quality time with the family. But, [...]

Open source CMS

nomey
Cross-platform
Anomey is a small but effective framework and CMS for developing and maintaining web sites. (GPL)
BIGACE
Cross-platform
BIGACE is a multi-site, multi-language and [...]

Web Development / Frameworks

Bitweaver
Cross-platform
Bitweaver is a free and open source web application framework and content management system. (LGPL)
CakePHP
Cross-platform
CakePHP is a rapid development framework for [...]

Web Development Utilities

CKeditor
Cross-platform
This HTML text editor brings to the web much of the power of desktop editors like MS Word. It’s lightweight [...]

TAG CLOUD


Fatal error: Call to undefined function get_theme_option() in /home/sitescod/public_html/wp-content/themes/chronicle/footer.php on line 14