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.

My home page lists all my recent posts, however it displays each post in its entirety. Is there any way I can force it to just show a preview, such as the first 10 lines?

This would enable views to quickly scroll through and see the topics recently blogged, rather than having to scroll through a recent post which is incredibly large.

(this also helps with more Ad impressions I believe)

Under Settings > Reading, there is the following option For each article in a feed, show ...Full Text / Summary but I think this is only for feeds (RSS).

Thanks


share|improve this question
add comment

3 Answers

First you can use the more-Tag when writing the post. WordPress will only Show the Part before the more-Tag and Show a Read-more-Link.

You can open the file with the Loop in the Active theme (normally index.php), Search for the_content(...) and replace it with the_excerpt().

share|improve this answer
add comment
function my_home_excerpt_length($length) {
    return 500; //about ten lines
}

function my_home_post_cropper($content) {
    if (!is_page() && (is_front_page() || is_home())) {
        add_filter('excerpt_length', 'my_home_excerpt_length');
        $content = wp_trim_excerpt($content);
        remove_filter('excerpt_length', 'my_home_excerpt_length');
    }
    return $content;
}

add_filter('the_content', 'my_home_post_cropper', 99); 
share|improve this answer
add comment

You might make use of the excerpt field on the post editing page to contain your post summary - this way, you can write specifically what you want to be shown on the homepage. You can then display the custom except by calling the_excerpt() in your homepage template.

I think this gives you more control than a text truncating solution as has been suggested.

share|improve this answer
add comment

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.