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 (value of "usp-author" Custom Field)
		Author ID   : display submitted posts from specified WP Author ID (e.g., 1, 2, 3, etc.)
			
numposts
		integer : display the specified number of submitted posts (default: display all posts)
			
display
		title   : display a list of submitted post titles (default)
		content : display the submitted post title and content
		excerpt : display the submitted post title and excerpt
		thumb   : display 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

Examples

Here are some examples showing different shortcode configurations:

[usp_pro_display_posts userid="1"]                       : display all submitted posts by registered user with ID = 1
[usp_pro_display_posts userid="current"]                 : display all submitted posts by author of current archive
[usp_pro_display_posts status="pending" userid="logged"] : display all pending posts from current logged-in user
[usp_pro_display_posts userid="Pat Smith"]               : display all submitted posts by author name "Pat Smith"
[usp_pro_display_posts loggedin="true"]                  : display all submitted posts only to logged-in users
[usp_pro_display_posts userid="all"]                     : display all submitted posts by all users/authors
[usp_pro_display_posts numposts="5"]                     : display 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.