Automating Excerpt

The excerpt filter by default cuts your post by a word count, which I think is probably preferable to a character-based substr function like you’re doing, and it strings out tags and images as well while doing it.

You can set the number of words to excerpt with the filter excerpt_length (it defaults to 55 words, this function from the codex shows how to change it to 20:)

function new_excerpt_length($length) {
    return 20;
}
add_filter('excerpt_length', 'new_excerpt_length', 999);

If you need to use a character-length based cutoff as in your example, you could fix broken tags and such just by applying an appropriate filter to your output, like this:

$content_to_excerpt = strip_tags( strip_shortcodes( get_the_content() ) ); 
echo "<p>". substr( apply_filters('the_excerpt', $content_to_excerpt), 0, 160)."...</p>";

Note that you’re stripping tags and applying the filters before truncating the excerpt, so as not to leave an open tag in your excerpt that will screw up the rest of your layout.

There are a number of great themes out there that deals with excerpts in creative ways, I advise you to take a look at how they do it. Here are a few good blog posts from people who have thought through the issue:

Also, for a really random way of dealing with excerpts, look at the Kirby theme – it tries to implement something like Microsoft Word’s autosummarize feature by using css to show only headers and lists (from what I remember).