• Resolved fredhead

    (@fredhead)


    Hi,

    This is my third, final for now, quick question. I’ve searched WP and Google to no avail:

    Is there a plugin or template tag that’ll let me grab only the first n words of a post for display on the home page?

    I’ve imported hundreds of my posts from Moveable Type and going back 20 posts to create excerpts with the <!–more–> tag will be a bit of work. I’m looking for a template tag that’ll just display a user-specified number of words in the post.

    I see that the Revolution template includes a plug-in, apparently, that limits content. I could not find a plugin in the WP list, or through Google.

    Any ideas, pointers, would be welcome. Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • you might find something here…

    http://robsnotebook.com/the-excerpt-reloaded

    Plugins are the easiest. A second way is to stick this in your theme’s function.php file…

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    function custom_trim_excerpt($text) { // Fakes an excerpt if needed
    global $post;
    if ( '' == $text ) {
    $text = get_the_content('');
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $text = strip_tags($text);
    $excerpt_length = x;
    $words = explode(' ', $text, $excerpt_length + 1);
    if (count($words) > $excerpt_length) {
    array_pop($words);
    array_push($words, '...');
    $text = implode(' ', $words);
    }
    }
    return $text;
    }

    A third option is to use the Excerpt box directly beneath the Write Post window. It will display whatever you type in the input field.

    Thread Starter fredhead

    (@fredhead)

    Thanks, Len! Any specific plugins to do this chore? Appreciate the code, at least.

    Yes, ronchicago just posted a link to one such plugin. There maybe more in the Plugin Directory – I don’t know as I didn’t look.

    Thread Starter fredhead

    (@fredhead)

    Thanks again, Ron, Len, this post can be marked as resolved.

    Thread Starter fredhead

    (@fredhead)

    For people who might find this topic, there also appears to be another plugin, which I found through one of my clients’ install, called Limit Posts. The URL is here:

    http://labitacora.net/comunBlog/limit-post.phps

    I find the Limit Posts plugin easier for my needs, but both it and the The Excerpt Reloaded plugins work fine.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Post excerpt options?’ is closed to new replies.