0

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


3 Answers 3

2

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().

1
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); 
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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