Plugin Planet

Premium WordPress Plugins

USP Pro version 2.3 introduces a new shortcode to display a list of submitted posts for any user and for any post type. This post explains how it works and how to customize the shortcode’s attributes to suit your needs.

Meet the Shortcode

To display a list of submitted post titles, add the following Shortcode to any WP Post, Page, or Custom Post Type:

[usp_pro_display_posts]

Customizing

The [usp_pro_display_posts] Shortcode provides several attributes that enable you to customize the list of submitted posts:

userid
			all         : display submitted posts from all users (default)
			logged      : display submitted posts from current logged-in user
			current     : display submitted posts from author of current archive page
			Author Name : display submitted posts from specified USP Author Name (value of "usp-author" Custom Field)
			Author ID   : display submitted posts from specified WP Author ID (e.g., 1, 2, 3, etc.)
			
numposts
			integer : displays the specified number of submitted posts (default: display all posts)
			
display
			title   : displays a list of submitted post titles (default)
			content : displays the submitted post title and content
			excerpt : displays the submitted post title and excerpt
			thumb   : displays only the featured image
			
loggedin
			false : display submitted posts for all users (default)
			true  : display submitted posts only if user is logged in
			
status
			publish : display only published submitted posts (default)
			pending : display only pending submitted posts
			draft   : display only draft submitted posts
			etc..   : display any valid Post Status: http://bit.ly/2bbUWFt
			
modlinks
			false : do not display "edit" and "delete" links for the post (default)
			true  : display "edit" and "delete" links for the post
			
formid
			integer : limits displayed posts to a specific USP Form (no default)
			
cat
			integer  : limits displayed posts to a specific category (e.g., 2) (no default)
			integers : limits displayed posts to multiple categories (e.g., 2,6,17,38) 
			
order
			DESC : orders posts in descending order (default)
			ASC  : orders posts in ascending order
			
orderby
			param : orders posts by any valid parameter (e.g., ID, author, title, et al) (default = date)
			
post_type
			any valid post type or 'any' for any post type (default = any)

You can find more info about these parameters at the WP Codex.

Examples

Here are some examples showing different shortcode configurations:

[usp_pro_display_posts userid="1"]                       : displays all submitted posts by registered user with ID = 1
[usp_pro_display_posts userid="current"]                 : displays all submitted posts by author of current archive page
[usp_pro_display_posts status="pending" userid="logged"] : displays all pending submitted posts from the current logged-in user
[usp_pro_display_posts userid="Pat Smith"]               : displays all submitted posts by author name "Pat Smith"
[usp_pro_display_posts loggedin="true"]                  : displays all submitted posts only to logged-in users
[usp_pro_display_posts userid="all"]                     : displays all submitted posts by all users/authors
[usp_pro_display_posts numposts="5"]                     : displays 5 most recent submitted posts
[usp_pro_display_posts display="excerpt"]                : display excerpts of submitted posts

As a bonus, the [usp_pro_display_posts] Shortcode displays any posts that were submitted by the free version of USP.

Theme Template

Just a tip: you can display any shortcode directly in your theme template using WP’s do_shortcode() function. So to display a list of user-submitted posts, you can do something like this:

<?php echo do_shortcode('[usp_pro_display_posts]'); ?>

And then flesh it out with any necessary shortcode attributes.

Advanced Customization

For advanced customization, the following filter hooks are provided:

usp_shortcode_display_posts_type
usp_shortcode_display_posts_size
usp_shortcode_display_posts_before
usp_shortcode_display_posts_after
usp_shortcode_display_posts_title
usp_shortcode_display_posts_edit_title
usp_shortcode_display_posts_edit_text
usp_shortcode_display_posts_delete_title
usp_shortcode_display_posts_delete_text
usp_shortcode_display_posts_modlink_sep1
usp_shortcode_display_posts_modlink_sep2

Check out the source code in /inc/usp-functions.php for more information.