Jepson Center for the Arts

WP Snapshot — A multi‐use Wordpress Plugin for Getting a Snippet of Text

Use WP Snapshot to auto-generate meta-descriptions, post summaries, page summaries and more. If you’re tired of manually writing your meta descriptions or post excerpts and want an easy way to grab a snippet of text to use on your Archive pages, then this plugin is the time-saver you’re looking for.

With redundant content checks, WP Snapshot will search your content and return the most relevant snippet of text to use as your meta-description, post summary (like in the sidebar on this site), post teaser, etc. It even has built-in defaults in case it can’t find applicable content.

What’s more, it’s fully customizable, allowing you to determine the text to use, the word limit, and the trailing text.

Installation

  1. Download the "mish_wp_snapshot.zip" folder, then extract.
  2. Upload the uncompressed folder to your plugin directory (wp-content/plugins).
  3. Activate the plugin through your Admin Dashboard.

Parameters

The plugin accepts 3 parameters; the custom text, the word limit, and the trailing text. Each parameter has to be set in order. See exmples for further information.

Content: The default usage is to find the relevant text to summarize by first checking for any custom text entered during installation, then checking for the post or page content, and finally—if it can’t find anything—resorting to built-in default text.

Word Limit: The default word limit is 27 words.

Trailing Text: The default trailing text is an ellipsis (…) because that indicates a trailing thought or edited text.

Usage

To call within your template, place the following code wherever you’d like the snapshot to appear.

<?php mish_wp_snapshot(); ?>

Example 1

Using the default on an Archive Page (Category, Author, Date-based, Tag, etc). Place the following within the LOOP in your template’s "archive.php" file:

<?php mish_wp_snapshot(get_the_content()); ?>

This will return something that looks like:

Here’s a quick function to determine whether or not the viewer is on the last page of a paginated post. It's useful if you want to display…

Example 2

Expanding on Example 1: Place the follwing within the LOOP on an Archive Page:

<?php mish_wp_snapshot(get_the_content(),'30', ' [more]'); ?>

This will return something that looks like:

Here’s a quick function to determine whether or not the viewer is on the last page of a paginated post. It's useful if you want to display information such as [more]

Notice how the post sumamry has been extended to add additional words, as well as replaced the ellipsis (…) with "[more]".

Example 3

The default usage as the meta-description on any page. Place this code in your "header.php" file:

<meta name="description" content="<?php mish_wp_snapshot('meta-desc'); ?>" />

WP Snapshot intuitively looks through the content of the post or page to find the appropriate text —based on the type of Page (is_category(), is_month(), is_single(), etc.)—to use for the meta-description.

Note: You must set the custom content parameter to "meta-desc" in order to use it as your meta description.

<meta name="description" content="A quick function to determine whether or not the viewer is on the last page of a paginated post. It's useful if you want to display information" />

Notice how the trailing text has been removed and the snippet of text is different than that displayed in the LOOP. This is because WP Snapshot first looks for a post excerpt to use as a meta description. If it can’t find that, it grabs the first 27 words of the post content. If that is blank (as is the case sometimes when using Pages), it grabs the title of the Page as the absolute default text.

Updates

Current Version: 0.5

Changelog:

  • v0.5 : December 8, 2008 : Initial release

Conclusion

I hope this comes in handy for someone when developing a theme or just for learning purposes. Whenever I develop a script, I intentionally try to break it, so I can spot areas of improvement. If you see any, feel free to let me know!

Reader Comments

→ Skip to Comment Form

December 26, 2008

hi. Thanks for plugin

perfect.

Regards

July 7, 2009

is this application supported by wordpress 2.8?

July 7, 2009

@guerremdq: Yep, I’m using it on this site and I’m running WP 2.8.

Leave a Comment

HTML is disabled in comments except for comment-author URLs. Additionally, comment moderation is enabled, meaning, if you don't see your comment either it’s your first time commenting, you’re spam, or there was a glitch in the filtering. If it’s two of the three (guess which) no worries, it’ll show up soon. However, this site reserves full right to remove any comment at its discretion.

If you want a commenter avatar, you can learn more about them here.

Privacy Notice:

No personal information is collected on this website. We also do not collect eMail addresses or telephone numbers of people who contact us directly. We will only use them to respond to your questions or comments.

Please complete the required fields: Name, Mail, Comments, Validation .

Click to close.

Snapshot: Post

Posted: December 8th, 2008

A Wordpress plugin to get a snippet of text to use for meta descriptions, snapshots of posts, blog teasers, etc.

Disclaimer: While this script may come in handy for others, I designed it specifically for use on this site. I haven’t tested it in any version of Wordpress other than those that I’ve used (v2.6.3–v2.8.6). Feel free to use it if you’d like, but I make no guarantee it will work with your current theme or Wordpress setup. For a complete Copyright Notice and Disclaimer, visit the About Section of this site.

Topics

Or you can check out the full archive here: Article Archive.

Search