web2feel.com – Free wordpress themes – Tutorials – Tips and tricks

Free WordPress Themes for everybody

Categories

On many of mine or other magazine type of 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

Leave a Reply

  1. swapnil says:

    Hi, this was just wonderful, now we can wholly customize our wordpress themes as we want.

  2. Selcuk says:

    Wow just wan´t to say, your themes are incredible! The most beautiful themes I´ve ever seen!

Feature your theme here

Sponsors

  • Theme forest
  • Gator
  • Your Ad Here
  • Your Ad Here
  • Your Ad Here

Recent Uploads

Wow!!! Browser giant Mozilla caught pants down plagiarizing MetaLab's design.

Contact Me

Your Name (required)

Your Email (required)

Subject

Your Message

4+1=?