Get Better Excerpt Plugin for WordPress

The Get Better Excerpt plugin works almost identical to the built in get_the_excerpt() and the_excerpt() functions except it returns whole words instead of cutting off the excerpt as the existing function does.

The plugin allows you to display the excerpt or read it to a variable, select the number of words to return and choose if you want the plugin to skip the built in excerpt and read from the content instead.

As with all my plugins, this is the code I use here on this is my url to return excerpts throughout the website. You’re free to download it.

Frequently Asked Questions

= How do I display the results? =
Insert the following code into your WordPress theme files: 
= General results =
ithout passing any parameters, the plugin will return ten results or fewer depending on how many posts you have.
 get_better_excerpt();
= Altering the before and after values =
By default the plugin wraps your code in list item (<li>) tags but you can specify how to format the results using the following code:
 get_better_excerpt(‘before=<p>&after=</p>’);
= Adding a Link = 
If you’d like to link to the post (remember it’s not live yet) you can do so by calling:
 get_better_excerpt(‘link=true’); 
= How many words? = 
You can specify the number of words returned using the option:
 get_better_excerpt(‘words=20′); 
 
 = Skip the excerpt? = 
If you would like to load the content directly, skipping the entered excerpt:
 get_better_excerpt(’skipexcerpt=true’); 
 = Include a trailing character? = 
By default the plugin includes a … after the excerpt, you can remove it or change it by altering:
 get_better_excerpt(‘trail=’); 
= Echo vs. Return =
Finally, if you’d like to copy the results into a variable you can return the results as follows:
 get_better_excerpt(’show=false’); 

 

4 Responses to “Get Better Excerpt Plugin for WordPress”

  1. [...] Get Better Excerpt Plugin for WordPress New! The Get Better Excerpt plugin works almost identical to the built in get_the_excerpt() and the_excerpt() functions except it returns whole words. [...]

  2. Victor says:

    I tried a straight substitute of the_content() with get_better_excerpt() in my theme’s index.php file and all I get is a blank space.

  3. Andrew Koop says:

    I’m having a the same trouble, Victor. Did you ever find a solution? Thanks.

  4. Brock says:

    I don’t know if you’re taking bug reports here, but this will address the previous two comments.

    The last line of the get_better_excerpt function tries to use $show, which is never instantiated. It currently reads:

    if ($show) {echo $excerpt;} else {return $excerpt;}

    But it should be:

    if ($ns_options['show']) {echo $excerpt;} else {return $excerpt;}

    Victor and Andrew, you have two options to fix your problem:

    1. Go into the get-better-excerpt.php file and replace that last line.
    2. In your theme where you call get_better_excerpt(), put an echo statement right before it. By default, the function is returning the excerpt instead of printing it out.

Leave a Reply