
Adds shortcodes to display the content of a post or a list of posts.
Author: | cgrymala (profile at wordpress.org) |
WordPress version required: | 4.3 |
WordPress version tested: | 4.9.5 |
Plugin version: | 1.0.1.1 |
Added to WordPress repository: | 30-08-2011 |
Last updated: | 03-04-2018
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 96 |
Rated by: | 31 |
Plugin URI: | http://plugins.ten-321.com/post-content-short... |
Total downloads: | 98 584 |
Active installs: | 3 000+ |
![]() Click to start download |
FAQ
Installation Instructions
Automatic Installation
The easiest way to install this plugin automatically from within your administration area.
- Go to Plugins -> Add New in your administration area, then search for the plugin “Post Content Shortcodes”.
- Click the “Install” button.
- Go to the Plugins dashboard and “Activate” the plugin (for MultiSite users, you can safely “Network Activate” this plugin).
Manual Installation
If that doesn’t work, or if you prefer to install it manually, you have two options.
Upload the ZIP
- Download the ZIP file from the WordPress plugin repository.
- Go to Plugins -> Add New -> Upload in your administration area.
- Click the “Browse” (or “Choose File”) button and find the ZIP file you downloaded.
- Click the “Upload” button.
- Go to the Plugins dashboard and “Activate” the plugin (for MultiSite users, you can safely “Network Activate” this plugin).
FTP Installation
- Download the ZIP file from the WordPress plugin repository.
- Unzip the file somewhere on your harddrive.
- FTP into your Web server and navigate to the /wp-content/plugins directory.
- Upload the post-content-shortcodes folder and all of its contents into your plugins directory.
- Go to the Plugins dashboard and “Activate” the plugin (for MultiSite users, you can safely “Network Activate” this plugin).
Must-Use Installation
If you would like to force this plugin to be active (generally only useful for Multi Site installations) without an option to deactivate it, you can upload the post-content-shortcodes.php & class-post-content-shortcodes.php files to your /wp-content/mu-plugins folder. If the mu-plugins folder does not exist, you can safely create it. Make sure not to upload the post-content-shortcodes folder into your mu-plugins directory, as “Must Use” plugins must reside in the root mu-plugins directory in order to work.
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 thepost-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 thepost-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 thepost-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.
There are also four actions that are executed (as of 0.6) within the plugin:
pcs_starting_post_content
– Fires when the post_content() function is entered; allows you to selectively add any special filters, etc. that need to be added just for use within the post-content shortcode.pcs_ending_post_content
– Fires before the output from the post_content() function is returned; allows you to remove any filters that you may have added in thepcs_starting_post_content
action.pcs_starting_post_list
– Fires when the post_list() function is entered; allows you to selectively add any special filters, etc. that need to be added just for use within the post-list shortcode.pcs_ending_post_list
– Fires before the output from the post_list() function is returned; allows you to remove any filters you may have added in thepcs_starting_post_list
action.
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 shortcodes) within the excerpt can break the entire page. In order to avoid this, be sure to place the tag above the shortcode within the posts being pulled into the post-list shortcode.
Why are the thumbnails/links wrong when using a Content Template from the Views plugin?
Unfortunately, because of the way the Views plugin processes posts, the [wpv-post-url], [wpv-post-link] and [wpv-post-featured-image] shortcodes do not work properly. Instead, you will need to use the [pcs-post-url] and [pcs-thumbnail] shortcodes.
1.0.1.1
- Adds i18n and l10n features so the plugin can be properly translated in the future
- Attempts to fix errant PHP warning about string/array conversion (h/t @codingbee)
1.0.1
- Fixes issue with the permalink that’s used in the “Read More” link on cross-site post lists
- Turns off debug message when site is installed on non-multisite install
- Update WP version compatibility
- Begin testing Gutenberg compatibility
- Fix undefined index warnings about
enable-site-settings
andtax_query
1.0
- Fixes PHP fatal error thanks to GitHub user @stefanogualdi
- Fixes other minor warnings and errors
- Adds plugin textdomain to all translatable strings
- Fixes some other minor PHP warnings
- Re-organizes code within plugin
- Fixes some issues with the way individual site options are handled in multisite
0.6
- Adds compatibility with Views plugin
- Adds new
link_image
attribute to wrap post thumbnail in a link (h/t @vince102, @MadManSam and @soft4tec) - Adds new
tax_term
andtax_name
attributes to help filter the list by taxonomy - Adds new
ignore_protected
attribute to leave password-protected posts out of the post-list (h/t @kapsol) - Adds new actions that fire at the beginning and end of the post_list and post_content functions (
pcs_starting_post_list
,pcs_ending_post_list
,pcs_starting_post_content
andpcs_ending_post_content
)
0.5.5
- Fixes issue that stopped widgets from working in WordPress 4.3
0.5
- Fixes error when used in some multisite/non-multisite instances, due to improper checking for multisite
- Fixes bug that stopped the date from showing up in the Post List shortcode/widget
- Remove calls to old-style widget constructor
- Update compatibility
0.4.1
- Fix strict standards warning about widget methods – h/t ux4341
- Special thanks also to spivurno for assistance in identifying the strict standards warnings
0.4
- Test for 4.0 compatibility
- Minor bug fixes
- Add “current-post-item” CSS class to the appropriate post within the post-list in response to request from thomas.mery
- Add post ID and shortcode attributes to items that can be sent through the
post-content-shortcodes-open-item
filter - Add post object and shortcode attributes to items sent through most filters
- Add new
post-content-shortcodes-include-thumbnail
filter to change the way the thumbnail is included in post content (if desired)
0.3.4.1
- Minor bug fix: On multisite, when pulling items with a custom taxonomy from another blog, an empty list would be returned because the taxonomy wasn’t registered
0.3.4
- Implement admin options for plugin
- Implement post content widget
- Implement post list widget
- Allow disabling default styles
- Attempt to fix issue with unbalanced shortcodes and HTML tags in post excerpts
- Add shortcode option to strip all HTML from post excerpts
- Begin implementing option to show comments with posts
- Remove manual database calls in favor of new, optimized
switch_to_blog()
- Improve performance
- Fix bug that stopped images from being displayed on cross-site post lists
- Added ability to specify blog name (slug) rather than blog ID to pull posts from another site
- Added ability to specify post slug rather than post ID to pull post
0.3.3
- Fix bug with the number of posts returned by
post_list
shortcode - Attempt to add tax_query args to
post_list
shortcode - Fix bug with category parameter
- Test compatibility with 3.6
- Fix image size bug when only width or height is defined (previously, the other dimension defaulted to 0; now, it defaults to 9999999px, instead, to ensure that the specified dimension is used)
- Start to flesh out the widgets a little more
0.3.2.1
- Fix image size bug introduced in 0.3.2
0.3.2
- Fix bug with the way post-list transients were stored (and therefore retrieved)
- Update class names to better match WP Coding Standards
- Add
pcsc-transient-timeout
filter for transient timeout (to allow shorter or longer caching of data) - Add ability to display title at top of
post-content
shortcode using theshow_title
attribute.
0.3.1
- Urgent bugfix (post-content shortcode wasn’t showing content)
0.3
- Added ability to display content of a post from another site in a multisite installation
- Added ability to list posts from another site in a multisite installation (uses shortlinks rather than permalinks)
- Fixed bug in orderby parameter of post-list shortcode
- Reduced transient timeout from 24 hours to 1 hour
- Added widgets to plugin (one to display a list of posts and one to display a single post)
- Added ability to display excerpt instead of content in post-content shortcode
- Added ability to limit length of content/excerpt shown in post-content shortcode
- Added ability to display featured image with post-content
0.2
- Attempted to fix issue with original readme file (no info from readme was showing up in the WordPress repo)
0.1a
This is the first version of this plugin