Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to make a page that has all the posts in it and shows 30% or less of the content of the post. So I'm editing a page template and I can't figure out how to show only 30% of the content. I'm new to this so please don't spam me with "go google it you noob" , stuff like that. Thank you in advance and have a nice day!

share|improve this question
    
i am sorry to spam you but you should check out the meaning of excerpt in wordpress codex.. codex.wordpress.org/Function_Reference/the_excerpt –  Sagive SEO Apr 13 '13 at 20:38

2 Answers 2

Go with the_excerpt.

It does what it is supposed to do. Give you an excerpt of your post.

Traditionally, it is set to display the first 55 words of your post. You can tweak it using filters to give more (or less) if needed to be.

http://codex.wordpress.org/Function_Reference/the_excerpt

share|improve this answer

As Marco said, use the excerpt to achieve that.

You can change the the_excerpt() function length using the following filter

function my_excerpt_length($length) 
{
return 30; // Here is the new length of your excerpt
}
add_filter('excerpt_length', 'my_excerpt_length');

You can add it to your theme functions.php file.

Alternatively, you may want to create a new function where you can have a better control over the content that will be display, I use the following function to achieve that sometimes:

function excerpt($limit) 
{
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) 
    {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt).' ';
} else {
    $excerpt = implode(" ",$excerpt);
} 
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}

You can then use it like this:

<?php echo excerpt(40); // 40 is the number of words that are going to be displayed ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.