WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Post Content Shortcodes

Adds shortcodes to display the content of a post or a list of posts.

How do I use this plugin?

To display the content of a single post within another post, you want to use the [post-content] shortcode. To display the content of the post with an ID of 25 and a slug of 'this-is-my-cool-post', the usage would look like:

[post-content id=25]

or

[post-content post_name="this-is-my-cool-post"]

To display a list of posts within another post, you want to use the [post-list] shortcode. To display a list of all pages (post_type=page) on this site, the usage would look like:

[post-list post_type="page"]

By default, this plugin will display all posts that match the specified criteria (except for the current post). To limit the number of posts that are displayed, you should add the numberposts argument to the shortcode. That would look like:

[post-list post_type="page" numberposts=15]

Does the shortcode output any extra HTML?

The [post-content] shortcode will not output any extra HTML at all. It simply outputs the content of the page being cloned. The original title is not output, nor is any sort of wrapper HTML.

The [post-list] shortcode, however, does output some HTML to actually format the list. The default HTML code output looks like:

<ul class="post-list">
<li class="listed-post"><a href="%permalink%" title="%title%">%title</a></li>
</ul>

How do I change the HTML output for the post-list?

There are some filters available within the plugin that can alter the HTML generated by the shortcode. Those filters are as follows:

  • post-content-shortcodes-open-list - filters the opening '<ul>' tag
  • post-content-shortcodes-open-item - filters the opening '<li>' tag
  • post-content-shortcodes-item-link-open - filters the opening '<a>' tag. Three parameters are available with this filter. The constructed '<a>' tag is sent as the first parameter, the permalink is the second and the title attribute is the third. The 'the_permalink' filter is applied to the permalink before it is sent or used, and the 'the_title_attribute' filter is applied to the title attribute before it is sent or used.
  • post-content-shortcodes-item-link-close - filters the closing '</a>' tag
  • post-content-shortcodes-close-item - filters the closing '</li>' tag
  • post-content-shortcodes-close-list - filters the closing '</ul>' tag

Are there any other filters in the plugin?

Yes.

  • If the [post-list] shortcode retrieves an empty list of posts/pages, it will normally return an empty string (so as not to disrupt the flow of the page). However, you can have the shortcode output a custom error message by hooking into the post-content-shortcodes-no-posts-error filter.
  • If you would like to use a different set of default values for the shortcode arguments, you can hook into the post-content-shortcodes-defaults filter. The array of default arguments is passed to that filter before it gets used.
  • If you would like to alter the output of the [post-content] shortcode (for instance, to wrap it in an HTML container, or to add content before or after), you can hook into the post-content-shortcodes-content filter. The constructed HTML output is passed as the first parameter, and the WordPress post object is passed as a second parameter.
  • If you would like to change the "Read More" link used in the [post-content] shortcode (if you are limiting the length of the content/excerpt), you can use the post-content-shortcodes-read-more filter to do so.
  • If you would like to modify the class used on the featured image (if appropriate), you can use the post-content-shortcodes-image-class to do that.
  • By default, the plugin uses 'thumbnail' as the size of the featured image. If you would like to use a different registered size, you can change that with the post-content-shortcodes-default-image-size filter.

Why isn't the current post included in the list of posts?

By default, the [post-list] shortcode excludes the current post (since that would cause somewhat of a loop in the user's mind; clicking on a link in the page only to have the page reload with the same content). To allow the current post to be displayed in the list of posts, set the exclude_current argument to 0. That might look something like:

[post-list exclude_current=0]

How do I pull posts from another blog in the network?

Use the blog attribute to specify which site/blog the post should be pulled from. The blog attribute can accept a blog ID (numeric) or a blog name (the slug of the blog).

Will this plugin work in a multisite environment?

Yes. You can safely network-activate this plugin, or even use it as a mu-plugin. To pull a post with a slug of 'this-is-my-cool-post' from a blog with an ID of 10 and a slug of 'mycoolsite', the usage would look something like:

[post-content post_name="this-is-my-cool-post" blog=10]

or

[post-content post_name="this-is-my-cool-post" blog="mycoolsite"]

Will this plugin work with multinetwork?

Yes. The way this plugin works, there is no distinction between multi-network & multisite. You can use the blog_id argument to pull posts from any site in the entire multi-network installation; regardless of which network they fall under.

Why is my page getting all messed up when I use this?

There is a known issue where HTML (especially [caption] shortcodes) within the excerpt can break the entire page. In order to avoid this, be sure to place the tag above the [caption] shortcode within the posts being pulled into the post-list shortcode.

Requires: 3.0 or higher
Compatible up to: 3.6.1
Last Updated: 2013-9-8
Downloads: 26,301

Ratings

5 stars
5 out of 5 stars

Support

0 of 3 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,2,2
50,2,1
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1
0,2,0
100,1,1
0,2,0