USP Pro really shines when it comes to ease of use: building forms and displaying submitted content is quick and easy with a complete collection of Shortcodes and Template Tags. USP Pro provides Template Tags that make it easy to display submitted post content, author information, file uploads, and more. This guide serves as a reference for the most commonly used USP Template Tags.

Menu

Primary Template Tags

Tag Name Tag Description Parameter Definitions
display_usp_form() Displays a USP Form based on input ID (uses usp_form in usp-shortcodes.php). Syntax: display_usp_form($id, $class);
  • $id – (string/integer/false) the id of the USP Form to display (required) (default: false)
  • $class – (string/false) optional custom classes as comma-sep list (displayed as class="aaa bbb ccc") (default: none)
usp_is_submitted() Returns a boolean (true/false) value indicating whether the specified post is user-submitted. Shortcode available for this tag.
  • $postId – (string/integer) the post to check (default: none or current ID when used in loop)
usp_get_submitted() Returns an array of submitted file URLs for the specified/current post.
  • $postId – (string/integer) the post to check (default: none or current ID when used in loop)
usp_get_images() Returns an array of the formatted URLs for image attachments. All attributes optional. Syntax: $images = usp_get_images('thumbnail', '', '', false, false); foreach ($images as $image) echo $image;
  • $size – (string) image size as thumbnail, medium, large, full, or any defined size (default: thumbnail)
  • $before – (string) text/markup displayed before the image URL (default: <img src=")
  • $after – (string) text/markup displayed after the image URL (default: " />)
  • $number – (string/integer/false) the number of images to display for each post (default: false = display all)
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
usp_get_files() Returns an array of the formatted URLs for post attachments. Syntax: $files = usp_get_files('', '', 3, false); foreach ($files as $file) echo $file;
  • $before – (string) text/markup displayed before the image URL (default: none)
  • $after – (string) text/markup displayed after the image URL (default: none)
  • $number – (string/integer/false) the number of images to display for each post (default: false = display all)
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
usp_ids() Returns an array of the IDs for post attachments. Syntax: $ids = usp_ids(false, false); foreach ($ids as $id) echo $id;
  • $number – (string/integer/false) the number of IDs to retrieve (default: false = display all)
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
usp_attachment_link() Returns a formatted set of links to attachment pages for each post. Syntax: echo usp_attachment_link(false, false, false, false, false, false, false)
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $fieldId – (string/integer/false) an optional, specific uploaded file (default: false = display all)
  • $number – (string/integer/false) the number of links to retrieve (default: false = display all)
  • $before_item – (string) text/markup to display before each item (default: {li})
  • $after_item – (string) text/markup to display after each item (default: {/li})
  • $before_list – (string) text/markup to display before all items (default: {ul})
  • $after_list – (string) text/markup to display after all items (default: {/ul})
usp_get_filename() Returns the filename of the specified attachment. Syntax: (in loop) echo usp_get_filename(false, '2');, (outside loop) echo usp_get_filename('2544', '3');
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $fieldId – (string/integer/false) an optional, specific uploaded file (default: false = display all)
usp_latest_attachment() Returns optionally formatted URL(s) of the latest attachment(s). Syntax: echo usp_latest_attachment('', '', false, false, 'file');
  • $before – (string) text/markup displayed before the image URL (default: none)
  • $after – (string) text/markup displayed after the image URL (default: none)
  • $number – (string/integer/false) the number of images to display for each post (default: 1)
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $url – (string) attachment, post, or file (default: file = no link, URL only)
usp_get_meta() Returns the value of the specified custom field. Syntax: usp_get_meta(false, false);
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $meta – (string/false) name of custom field (default: usp-author)
usp_get_all_meta() Returns all usp custom fields for current or specified post. Example Syntax: $usp_meta = usp_get_all_meta(false); foreach ($usp_meta as $key => $value) echo $key . ' => ' . $value . "\n";
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
usp_get_image() Returns formatted images from within post loop, or the same for specified images outside the loop (i.e., anywhere in the theme). All attributes optional. Syntax: echo usp_get_image(false, false, false, false, false, '', '', '', '', false, false, false, false, false);
  • ids (note: plural) – (string/false) comma-separated list of attachment IDs (default: empty = all images)
  • size – (string/false) attachment size: thumbnail, medium, large full, or any defined size (default: thumbnail)
  • icon – (boolean) whether to use a media icon for the attachment (default: false)
  • number – (string/integer/false) the number of images for which to retrieve data (default: empty = display all)
  • link – (string/false) href value for link: file, attachment, parent, image, http://example.com/ (default: empty = no link, image only)
  • beforeitem – (string) text/markup to display before each item (default: {span class="usp-image-wrap"})
  • afteritem – (string) text/markup to display after each item (default: {/span})
  • beforelist – (string) text/markup to display before all items (default: {div class="usp-images-wrap"})
  • afterlist – (string) text/markup to display after all items (default: {/div})
  • link_class – (string/false) additional classes (defaults to lightbox)
  • link_att – (string/false) optional attribute(s) for links. Note: you can use #id#" to include the current post ID (default: rel="lightbox")
  • link_title – (string/false) title for links when enabled (default: use attachment description for title)
  • img_class – (string/false) class name(s) for each image (default: usp-image)
  • img_att – (string/false) optional attribute(s) for images. Note: you can use #id#" to include the current post ID (default: target="_blank")
usp_get_author_link() Returns author name from custom field as a link (if URL exists) or plain text (if URL not available). Syntax: echo usp_get_author_link();
  • No parameters for this template tag.
usp_get_avatar() Returns the avatar (image) of the specified submitter. Syntax: echo usp_get_avatar(false, false, false, false, false);
  • $postId – (string/integer/false) an optional post ID to use (default: false/none or current ID when used in loop)
  • $id_or_email – (integer/string) an optional email to use (default: false/none)
  • $size – (integer) optional size of avatar (max: 512, default: 96)
  • $default – (string/false) optional default image URL (default: WP “Mystery Man”)
  • $alt – (string/false) optional alt-text for image alt attribute (default: false/none)
usp_video_url() Returns url(s) of uploaded video(s). Currently supported video formats: mp4, m4v, webm, ogv, wmv, flv.
Syntax: $video_urls = usp_video_url(false, false, false); foreach ($video_urls as $video_url) echo $video_url;
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $fieldId – (string/integer/false) an optional, specific uploaded file (default: false = display all)
  • $number – (string/integer/false) the number of video URLs to retrieve (default: false = display all)
usp_audio_url() Returns url(s) of uploaded audio file(s). Currently supported audio formats: mp3, ogg, wma, m4a, wav.
Syntax: $audio_urls = usp_audio_url(false, false, false); foreach ($audio_urls as $audio_url) echo $audio_url;
  • $postId – (string/integer/false) the post to check (default: none or current ID when used in loop)
  • $fieldId – (string/integer/false) an optional, specific uploaded file (default: false = display all)
  • $number – (string/integer/false) the number of audio URLs to retrieve (default: false = display all)

Secondary Template Tags

Tag Name Tag Description Parameter Definitions
display_usp_login() Displays a Login/Register/Password Form. Located in /inc/usp-login.php. Syntax: display_usp_login();
  • No parameters for this template tag.
usp_get_form_id() Returns the post ID based on id or slug. Located in /inc/usp-forms.php. Syntax: $form_id = usp_get_form_id($form_id);
  • $form_id – (string/integer) (required) the post ID (id or slug)
usp_get_ip() Returns the current IP address. Located in /inc/usp-forms.php. Syntax: $ip_address = usp_get_ip();
  • No parameters for this template tag.
usp_is_contact() Checks if form is contact form, returns true or false. Located in /inc/usp-forms.php. Syntax: $is_contact = usp_is_contact($form_id);
  • $form_id – (string/integer) (required) the post ID (id or slug)
usp_check_malicious() Checks string for malicious input, returns true or false. Meant for use with email input, see source.
Located in /inc/usp-forms.php. Syntax: $is_malicious = usp_check_malicious($input);
  • $input – (string) (required) string to check
usp_clean() Cleans up input strings. Located in /inc/usp-forms.php. Syntax: $clean_string = usp_clean($string);
  • $string – (string) (required) string to clean
usp_return_bytes() Returns number in bytes. Located in /inc/usp-forms.php. Syntax: $bytes = usp_return_bytes($value);
  • $value – (string) (required) string to convert
usp_return_bool() Returns boolean response, “Enabled” or “Disabled”. Located in /inc/usp-forms.php. Syntax: $boolean = usp_return_bool($value);
  • $value – (string) (required) string to convert
usp_get_art_directed() Includes any art-directed content for the current post. Usage: automatic functionality (you don’t need to include/use any template tag). To use, attach to a post any of the custom-fields listed in the next column. Tip: you can auto-attach art-directed custom-fields to submitted posts using a hidden custom input with the following value, for example:

name#001|type#hidden|value#body{color:red;}

More info »

  • usp-custom-001 – any art-directed CSS (will be wrapped with <style> tags)
  • usp-custom-002 – any art-directed JavaScript (will be wrapped with <script> tags)
  • usp-custom-003 – any art-directed text/HTML (will not be wrapped with anything)

Notes & Resources

  • You can learn more about Template Tags in the WP Codex.
  • Many of the Template Tags also are available in Shortcode flavor.
  • All Template Tag attributes are optional unless stated otherwise.
  • Check out /inc/usp-functions.php for additional notes about some of the Template Tags covered in this guide.
  • In addition to the Template Tags provided by USP Pro, there are numerous default WordPress Template Tags, as well as any Template Tags that may be included with your theme and/or active plugins.