{"id":33866,"date":"2019-03-01T12:29:33","date_gmt":"2019-03-01T12:29:33","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33866"},"modified":"2019-05-28T14:22:42","modified_gmt":"2019-05-28T14:22:42","slug":"attributes-of-custom-shortcodes","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/attributes-of-custom-shortcodes\/","title":{"rendered":"Attributes of custom shortcodes"},"content":{"rendered":"<p class=\"h2\">Table of contents<\/p>\n\n<ol><li><a href=\"#intro\">Intro<\/a><\/li><li><a href=\"#how-to-create-attribute\">How to create attribute<\/a><\/li><li><a href=\"#field-name-and-description\">Field name and description<\/a><\/li><li><a href=\"#attribute-name\">Attribute name<\/a><\/li><li><a href=\"#default-value\">Default value<\/a><\/li><li><a href=\"#field-type\">Field type<\/a><ol><li><a href=\"#text\">Text<\/a><\/li><li><a href=\"#number\">Number<\/a><\/li><li><a href=\"#color\">Color<\/a><\/li><li><a href=\"#dropdown\">Dropdown<\/a><\/li><li><a href=\"#switch\">Switch<\/a><\/li><li><a href=\"#icon\">Icon<\/a><\/li><li><a href=\"#media-library\">Media library<\/a><\/li><li><a href=\"#image-source\">Image source<\/a><\/li><\/ol><\/li><\/ol><\/li><\/ol>\n\n\n<h2 class=\"wp-block-heading\" id=\"intro\">Intro<\/h2>\n\n\n\n<p>You can create attributes during creation of custom shortcodes. Attributes are shortcode settings. Using the attributes you can, for example, create two identical shortcodes of different colours or sizes. Created attributes will be available in shortcodes creator, at insertion of a custom shortcode to post editor.<\/p>\n\n\n\n<p>This is how shortcode without attributes\/settings looks like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[divider]<\/pre>\n\n\n\n<p>and this is a shortcode with attributes\/settings:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[divider color=\"red\"]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-create-attribute\">How to create attribute<\/h2>\n\n\n\n<p>While creating\/editing custom shortcode, find Attributes section and press Add attribute button. You can add any number of attributes. Settings for creation of attributes are described below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"field-name-and-description\">Field name and description<\/h2>\n\n\n\n<p>Full name of the field and its description. This text will be shown in shortcode creator at insertion of a shortcode into page editor.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"408\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu.png\" alt=\"\" class=\"wp-image-33867\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu.png 538w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu-512x388.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu-128x97.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu-80x61.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu-24x18.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-Fnp7DnJWeu-158x120.png 158w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"attribute-name\">Attribute name<\/h2>\n\n\n\n<p>Attribute&#8217;s short name. This name will be used at insertion of a shortcode into editor. This field can be filled with Latin letters in lower case [a..z], figures [0..9], and underscore &#8220;_&#8221; only. Example: use&nbsp;<em>color<\/em>&nbsp;as a name, and the shortcode will look like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[shortcode color=\"\"]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"default-value\">Default value<\/h2>\n\n\n\n<p>This value will be used as attribute value, unless any other value is specified at insertion of shortcode into editor.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"field-type\">Field type<\/h2>\n\n\n\n<p>This setting indicates the field type which will be used in shortcode creator at insertion of shortcode to page editor. All available field types are described below, in &#8220;Field types&#8221; section of the article.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"text\">Text<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"128\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy.png\" alt=\"\" class=\"wp-image-33868\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy.png 538w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy-512x122.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy-128x30.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy-80x19.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy-24x6.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-qSTQdVDVCy-280x67.png 280w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>Simple text field. Possible default value: any text.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"number\">Number<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"128\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca.png\" alt=\"\" class=\"wp-image-33869\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca.png 538w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca-512x122.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca-128x30.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca-80x19.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca-24x6.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-g9af6FIIca-280x67.png 280w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>Field for selection of number. Allows to select number using slider or text field. Allows to set minimum and maximum values and slider increments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"color\">Color<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"305\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS.png\" alt=\"\" class=\"wp-image-33870\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS.png 538w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS-512x290.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS-128x73.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS-80x45.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS-24x14.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-8WM7zuKZyS-212x120.png 212w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>Field for selection of colour. Allows to select color from drop-down color ring.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"dropdown\">Dropdown<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"539\" height=\"109\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI.png\" alt=\"\" class=\"wp-image-33871\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI.png 539w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI-512x104.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI-128x26.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI-80x16.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI-24x5.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-5SYqPfT5HI-280x57.png 280w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/figure>\n\n\n\n<p>Dropdown list. When adding this attribute, dropdown options should be set as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">value1|Option 1<br>value2|Option 2<\/pre>\n\n\n\n<p><em>value1<\/em>&nbsp;text will be inserted into post editor as attribute value as shown in code below.&nbsp;<em>Option 1<\/em>&nbsp;text will be shown in shortcode creator at insertion of shortcode.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[shortcode dropdown=\"value1\"]<\/pre>\n\n\n\n<p>&nbsp;Use one of the values specified in Dropdown options field as a default values, for example&nbsp;<em>value1<\/em>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"switch\">Switch<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"123\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV.png\" alt=\"\" class=\"wp-image-33872\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV.png 537w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV-512x117.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV-128x29.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV-80x18.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV-24x5.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-mmFgKauEPV-280x64.png 280w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<p>Field with selection of value between Yes and No. Possible default values:&nbsp;<em>yes<\/em>,&nbsp;<em>no<\/em>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"icon\">Icon<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"163\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r.png\" alt=\"\" class=\"wp-image-33873\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r.png 537w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r-512x155.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r-128x39.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r-80x24.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r-24x7.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-0tYBUFOT6r-280x85.png 280w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<p>Field for icon picker. Possible default values: name of vector icon in &#8220;icon: ICON_NAME&#8221; format or link to the image (for example:&nbsp;http:\/\/example.com\/image.jpg).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"media-library\">Media library<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"164\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO.png\" alt=\"\" class=\"wp-image-33874\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO.png 537w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO-512x156.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO-128x39.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO-80x24.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO-24x7.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-ySQkz6iiwO-280x86.png 280w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<p>Field for selection of image from media library. When selecting the image, link to it will be inserted. Possible default values: link to the image (for example:&nbsp;http:\/\/example.com\/image.jpg).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"image-source\">Image source<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"96\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc.png\" alt=\"\" class=\"wp-image-33875\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc.png 537w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc-512x92.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc-128x23.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc-80x14.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc-24x4.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-UF6yQlczdc-280x50.png 280w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"175\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ.png\" alt=\"\" class=\"wp-image-33876\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ.png 538w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ-512x167.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ-128x42.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ-80x26.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ-24x8.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2019\/03\/file-wqbTG8P3uZ-280x91.png 280w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>Advanced field for selection of several images from the media library. Allows to create image galleries, sliders, etc. IDs of selected images divided by decimal points will be added as attribute values. Possible default values: list of image IDs divided by decimal points.<\/p>\n","protected":false},"featured_media":0,"template":"","docs_category":[25],"class_list":["post-33866","docs","type-docs","status-publish","hentry","docs_category-addons"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33866"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}