Plugin / Get Post

James Tatum

Description

Description

Get Post adds a tag that allows you to retrieve and display the latest post
identified by a specific set of parameters.

When this plugin is active, any post or page can contain the get-post markup
as follows:

[get-post tag=some-tag]

This will be replaced with the latest post tagged with the given tag.

Parameters

The parameters control which posts are retrieved by get-post. Options can be
used in combination to build a list of criteria for post or posts to retrieve.
By mixing criteria, you can exert a lot of control over the post(s) which are
found by the plugin.

[get-post tag=some-tag random show=3]

One note on WordPress in general: if you specify criteria that WordPress can’t
match, it will make something up. For instance, if you specify a tag or
category that doesn’t exist, it will simply retrieve the latest post with no
indication that anything is wrong. Take care to ensure that the options you
specify are what you intend.

Several of these parameters work best when specifying the slugs. For instance,
when specifying a tag it’s best to use the slug value rather than the full
name of the tag. To find the slug, see the admin panel -> posts -> post tags.
The slug is listed right on that page.

You may wish to specify an option value with a space in it. This is
accomplished with quotes:

[get-post option="a value with spaces"]
  • tag:
    Specify a tag to search for. The tag’s slug should be specified.

    [get-post tag=some-tag]
    
  • category:
    Specify a category to search for. The category’s slug should be specified.

    [get-post category=some-category]
    
  • show:
    Specify the number of posts to show.

    [get-post show=5]
    
  • template:
    Specify the template to use. This specification overrides the template set in
    the options panel of the admin interface. See the template section for more
    details on template tags. NOTE: If entering any HTML into this, please be
    sure to select the HTML editor rather than the visual editor.

    [get-post template="<h1>Title: {title}</h1>"]
    
  • random:
    Select a random post from the matching criteria

    [get-post random]
    
  • default:
    This isn’t really an option. By default, get-post displays the latest blog
    post.

    [get-post]
    

Templates

Get-post ships with a default template that should render the usual post
details in a form that fits well with most themes. You can customize this
template to add or remove data from the included post. Additionally, you can
use the template parameter to the [get-post] tag to specify a one-off
template.

Using the show parameter will retrieve multiple posts. In this case, the
template will be repeated one time for each retrieved post.

These tags are replaced with the value from the retrieved post. For instance,
a template containing {title} will actually have the title of the retrieved
post, rather than the word title.

  • {title}:
    The title of the post.

  • {content}:
    The content of the post.

  • {author}:
    The author of the post.

  • {date}:
    The date the post was written.

  • {time}:
    The time the post was written.

  • {permalink}:
    A link to the post itself.

  • {authorlink}:
    A link to all posts by the post’s author.

  • {id}:
    The post’s ID number.

Examples

Indicate when your blog was last updated:

Blog last updated [get-post template="{date} at {time}."]

Link to the latest post:

Check out my post: [get-post template="<a href='{permalink}'>{title}</a>"]

How it works

This plugin does something a little bit unorthodox: It reenters “The
Loop”
while the post content is being rendered. Then, it calls
whatever WordPress internal functions will safely work, using raw data from
$post when these functions are unsafe to call again. People curious about the
internals should examine class-get-post-getter.php. The class is structured
to be reusable by any other GPL2 projects.

Ratings

0
0 reviews

Rating breakdown

Details Information

Version

2.0.0

First Released

25 Nov, 2008

Total Downloads

12,963

Wordpress Version

3.0 or higher

Tested up to:

3.1.4

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.