Types and Views allow you to write shortcodes inside of other shortcodes. This is useful when you want to use custom field values inside of other shortcodes.

Types and Views will process nested shortcodes in these cases:

  • [types field] – used to display data from a Types field for a post
  • [types usermeta] – used to display data from a Types usermeta field
  • [wpv-post-***] – used to display information from the current post (reference)
  • [wpv-taxonomy-***] – used to display information from the current taxonomy term in a View listing taxonomies (reference)
  • [wpv-user field] – used to display data from the user being displayed in a View listing users (reference)
  • [wpv-current-user] – used to display information from the current visitor (reference)

In addition, if the String Translation addon for WPML is active, we will process the [wpml-string] shortcode too by default.

You can nest shortcodes to one level.

Third-party shortcode arguments

You can add your own custom shortcodes so they can be used inside other shortcodes. Go to Toolset->Settings and click on the Front-end Content tab. Look for the section called Third-party shortcode arguments:

Views - Third party shortcode arguments
Views – Third party shortcode arguments

Also, if you are a developer, you can add your custom shortcodes from your own code using our filter wpv_custom_inner_shortcodes:

/**
* Filter the custom inner shortcodes array to add your own shortcode 'myshortcode'
* @param $shortcodes (array)
* @return $shortcodes
*/
add_filter('wpv_custom_inner_shortcodes', 'prefix_add_my_shortcodes');

function prefix_add_my_shortcodes($shortcodes) {
    $shortcodes[] = 'myshortcode';
    return $shortcodes;
}

The shortcodes that you register using this filter will also be listed in the same section of the Settings page, under the Shortcodes registered automatically section.

List Of Automatically Registered Third-Party Shortcodes
List Of Automatically Registered Third-Party Shortcodes

Practical Example

Let’s look at a practical example of a website that sells iPhone applications. You have created a shortcode that displays your app:

[app id='12345']

The 12345 is the ID of the of the app. But it may be that you want more control over the ID of the application using a custom field.

It’s simple. Just insert the custom field shortcode into the app shortcode:

[app id='[types field="app-id"][/types]']

With this, you’ll be able to include the ‘app’ shortcode in Content Templates and specify the application in a custom field, when editing content.