This tutorial explains the difference between the setting, “Featured Image Key”, and the shortcode attribute, “key”. They look similar but are not related functionality-wise. Read on to learn more.

Featured Image Key

The Uploads setting, “Featured Image Key”, enables you to specify which submitted image will be used as the Featured Image for the submitted post. So for example, if your form enables the user to upload five images, you can specify that, say, the third image is used as the Featured Image. To make it happen, visit the Uploads settings and set the following options:

  • Featured Images – Check box to enable
  • Featured Image Key – enter “3”

Done. The submitted post will now automatically use the third uploaded image as the Featured Image (aka Post Thumbnail).

The “key” attribute

The other similar feature of USP Pro is the key attribute that can be added to the [usp_files] shortcode. The key attribute enables you to specify a custom numerical value for the field name. That’s a bit abstract, so let’s look at an example.

Let’s say that your form has a file upload field created via the [usp_files] shortcode. By default, the field name of this input will be usp-file-1. This is fine for all practical purposes, but let’s say that you would like to change the numerical portion of this name to 123 (or any other number). Easy, just add key to the shortcode like so:

[usp_files key="123" required="true"]

Boom! Done. That will result in the following form markup for the file field:

<input name="usp-file-123" type="file" data-required="true">
<input name="usp-file-key" value="123" type="hidden">

As you can see, the name of the field now is usp-file-123, so when the image is processed and attached as a custom field to the submitted post, the custom field name also will be usp-file-123. In other words, the key attribute basically is just an easy way to change the name of the custom field.

Note that the key attribute works only when the multiple attribute is set to false.

Learn more about the files shortcode and its attributes.

References