{"id":2085,"date":"2023-05-30T09:33:57","date_gmt":"2023-05-30T09:33:57","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/?post_type=wpcode_doc&#038;p=2085"},"modified":"2026-10-05T09:49:01","modified_gmt":"2026-10-05T13:49:01","slug":"shortcode-attributes","status":"publish","type":"wpcode_doc","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/","title":{"rendered":"Using Shortcode Attributes"},"content":{"rendered":"<p>Would you like one snippet to show different text everywhere you place it?<\/p>\n<p>In this guide, we&#8217;ll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you&#8217;d like to reuse.<\/p>\n<ul class=\"toc\">\n<li><a href=\"#registering-shortcode-attributes\">Registering Shortcode Attributes<\/a><\/li>\n<li><a href=\"#inserting-attribute-values-with-smart-tags\">Inserting Attribute Values with Smart Tags<\/a><\/li>\n<li><a href=\"#using-attribute-values-as-php-variables\">Using Attribute Values as PHP Variables<\/a><\/li>\n<li><a href=\"#copying-the-shortcode-and-passing-values\">Copying the Shortcode and Passing Values<\/a><\/li>\n<li><a href=\"#filling-in-attributes-with-the-wpcode-block\">Filling In Attributes with the WPCode Block<\/a><\/li>\n<li><a href=\"#checking-the-result-on-your-site\">Checking the Result on Your Site<\/a><\/li>\n<\/ul>\n<p>Before you get started, make sure WPCode is <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/how-to-install-the-wpcode-plugin\/\" target=\"_blank\">installed and activated<\/a> on your WordPress site.<\/p>\n<h2 id=\"registering-shortcode-attributes\">Registering Shortcode Attributes<\/h2>\n<p>A shortcode attribute is a named value you hand to a snippet at the moment you place its shortcode. One snippet holding the markup for a book review callout can then produce a different title and author on every page that uses it. You only ever maintain the one snippet.<\/p>\n<p>WPCode asks you to register each attribute name on the snippet first. That way the snippet accepts exactly the values you planned for, and nothing else.<\/p>\n<p>To get started, go to <strong>Code Snippets &raquo; Code Snippets<\/strong> in your WordPress admin sidebar. Then open the snippet you want to use as a shortcode.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_01_navigate.webp?v=9926dcec\" alt=\"The Code Snippets list in WordPress with the Code Snippets menu open in the sidebar, showing a snippet called Book Review Callout with the ID 512\" \/><\/p>\n<p>Attributes belong to snippets that run as shortcodes.<\/p>\n<p>Inside the snippet editor, scroll down to the Insertion section. Then choose <strong>Shortcode<\/strong> as the insert method.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_02_insert_method_shortcode.webp?v=877b8779\" alt=\"The Insert Method row in the WPCode snippet editor with a red arrow pointing at the Shortcode button beside Auto Insert\" \/><\/p>\n<p>Choosing Shortcode swaps the Location picker for the four rows that control the shortcode.<\/p>\n<ul>\n<li><strong>Shortcode<\/strong>: the ready-made shortcode for this snippet. WPCode builds it from the snippet ID for you, and rebuilds it every time you save.<\/li>\n<li><strong>Custom Shortcode<\/strong>: a name of your own to use in place of the ID-based shortcode. The ID-based shortcode keeps working whether you fill this in or not.<\/li>\n<li><strong>Shortcode Attributes<\/strong>: the list of attribute names this snippet accepts. The list starts empty, and only the names you add here are read from the shortcode.<\/li>\n<li><strong>Locations Used<\/strong>: a search that turns up the posts and pages where this shortcode already appears.<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_03_shortcode_fields.webp?v=161eda14\" alt=\"The Shortcode, Custom Shortcode, Shortcode Attributes, and Locations Used rows in the WPCode Insertion section, with the attributes list still empty\" \/><\/p>\n<p>Attribute names use lowercase letters, numbers, and underscores. WPCode lowercases what you type and drops every other character as you type it, so &#8220;Book Title&#8221; arrives as <code>booktitle<\/code>.<\/p>\n<p>Next, type a name into the attribute field. Then click <strong>Add Attribute<\/strong>.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_04_add_attribute.webp?v=915effa7\" alt=\"The Shortcode Attributes field with book_title typed into it and a red arrow pointing at the Add Attribute button\" \/><\/p>\n<p>Each name you add lands in a list under the field, with a delete icon beside it for removing it again. Add one name for every value you want to pass in.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_05_attributes_registered.webp?v=026867e4\" alt=\"The WPCode Shortcode Attributes list showing two registered attributes, book_title and book_author, each with a delete icon\" \/><\/p>\n<div class=\"alert alert-info\">\n<p><strong>Note:<\/strong> This list is the complete set of attributes the snippet reads. An attribute you write into the shortcode without registering it here is ignored.<\/p>\n<\/div>\n<p>With the names registered, WPCode gives you two ways to read their values in your snippet code.<\/p>\n<h2 id=\"inserting-attribute-values-with-smart-tags\">Inserting Attribute Values with Smart Tags<\/h2>\n<p>Registering a name also creates a <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/smart-tags\/\" target=\"_blank\">smart tag<\/a> for it. The tag is the attribute name with an <code>attr_<\/code> prefix, wrapped in curly braces, so <code>book_title<\/code> becomes <code>{attr_book_title}<\/code>. WPCode swaps the tag for whatever value the shortcode passed, and escapes that value on the way through, which makes this the route we recommend.<\/p>\n<div class=\"alert alert-warning\">\n<p><strong>Requirements<\/strong>: Smart tags are available in the paid versions of WPCode.<\/p>\n<\/div>\n<p>Above the code editor, click <strong>Show Smart Tags<\/strong>.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_06_show_smart_tags.webp?v=1d3bca63\" alt=\"The Code Preview header in the WPCode snippet editor with a red arrow pointing at the Show Smart Tags link\" \/><\/p>\n<p>The picker lists every tag this snippet can use. Because your attributes all share the <code>attr_<\/code> prefix, typing <code>attr<\/code> in the search box narrows the list to just them. WPCode groups them under a Shortcode Attributes heading.<\/p>\n<p>In the filtered list, click the tag you want.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_07_attribute_smart_tag.webp?v=08344208\" alt=\"The WPCode Smart Tags picker filtered by the search term attr, showing a Shortcode Attributes group with the tags attr_book_title and attr_book_author, and a red arrow pointing at attr_book_author\" \/><\/p>\n<p>WPCode drops the tag into the code at your cursor. Repeat for each attribute, placing every tag where you want its value to appear.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_08_tag_inserted.webp?v=15161769\" alt=\"An HTML snippet in the WPCode editor using the smart tags attr_book_title and attr_book_author inside a bordered div\" \/><\/p>\n<p>The tags show up in the picker the moment you add an attribute. You can register a name and use it in the same editing session. Smart tags resolve in <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/what-type-of-snippet-do-i-need\/\" target=\"_blank\">HTML, Text, JavaScript, and Universal snippets<\/a>.<\/p>\n<p>PHP snippets read their attribute values a different way, straight from PHP variables.<\/p>\n<h2 id=\"using-attribute-values-as-php-variables\">Using Attribute Values as PHP Variables<\/h2>\n<p>In a PHP or Universal snippet, every registered attribute arrives as a PHP variable named after it. An attribute called <code>book_title<\/code> is available as <code>$book_title<\/code>, and one called <code>book_author<\/code> as <code>$book_author<\/code>.<\/p>\n<p>The variable exists as soon as the name is registered. It holds an empty string when the shortcode leaves that attribute out, so there&#8217;s no need to test for it first.<\/p>\n<p>Escaping is yours to handle on this route. Pass the value through a function such as <code>esc_html()<\/code> before printing it.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_09_php_variables.webp?v=5e1219d5\" alt=\"A PHP snippet in the WPCode editor echoing the variables book_title and book_author through esc_html, with the Code Type set to PHP Snippet\" \/><\/p>\n<p>Both routes read the same registered attributes, so a Universal snippet can use whichever one suits each part of its code.<\/p>\n<p>Every value the snippet reads comes from the shortcode you place, so that shortcode is the last piece to put together.<\/p>\n<h2 id=\"copying-the-shortcode-and-passing-values\">Copying the Shortcode and Passing Values<\/h2>\n<p>Once the attributes are registered and your code reads them, click <strong>Update<\/strong> to save the snippet.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_10_update_snippet.webp?v=4ad70b2f\" alt=\"The WPCode snippet editor header with a red arrow pointing at the Update button\" \/><\/p>\n<p>Saving rebuilds the Shortcode field with your attributes already listed as empty placeholders, ready to fill in.<\/p>\n<p>When the field reappears, click <strong>Copy<\/strong> to put the shortcode on your clipboard.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_11_copy_shortcode.webp?v=6e9583c1\" alt=\"The Shortcode field reading wpcode id 512 with empty book_title and book_author attributes, and a red arrow pointing at the Copy button\" \/><\/p>\n<p>That shortcode goes wherever the snippet should appear, whether that is a widget, a page builder module, or a Classic block. New to placing shortcodes? See <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/www.wpbeginner.com\/wp-tutorials\/how-to-add-a-shortcode-in-wordpress\/\" target=\"_blank\" rel=\"nofollow\">How to Add a Shortcode in WordPress<\/a> for a step-by-step walkthrough.<\/p>\n<p>Each value sits between its own pair of quotes. The snippet ID belongs to the snippet you just saved, so yours will be a different number.<\/p>\n<p><code>[[wpcode id=\"512\" book_title=\"Around the World in Eighty Days\" book_author=\"Jules Verne\"]]<\/code><\/p>\n<p>If you gave the snippet a name in the <strong>Custom Shortcode<\/strong> field, use that name in place of the ID. The attributes work in exactly the same way:<\/p>\n<p><code>[[book_review book_title=\"Around the World in Eighty Days\" book_author=\"Jules Verne\"]]<\/code><\/p>\n<div class=\"alert alert-warning\">\n<p><strong>Requirements<\/strong>: Custom shortcode names are available in the paid versions of WPCode.<\/p>\n<\/div>\n<p>In the block editor, WPCode can handle all of that for you instead.<\/p>\n<h2 id=\"filling-in-attributes-with-the-wpcode-block\">Filling In Attributes with the WPCode Block<\/h2>\n<div class=\"alert alert-warning\">\n<p><strong>Requirements<\/strong>: The WPCode block is available in the paid versions of WPCode.<\/p>\n<\/div>\n<p>WPCode adds a block of its own to the WordPress editor, and it is built around this feature. The block reads the attribute names you registered and shows one field for each of them. The values go into a form rather than between quotes.<\/p>\n<p>To place the snippet, open the post or page where you want it to appear. Then add the <strong>WPCode<\/strong> block.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_12_wpcode_block_inserter.webp?v=e0e2d891\" alt=\"The WordPress block inserter with wpcode typed into its search box and a red arrow pointing at the WPCode block result\" \/><\/p>\n<p>In the block settings on the right, pick your snippet from the <strong>Choose snippet<\/strong> dropdown. The block renders that snippet&#8217;s output in the editor as soon as you choose it.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_13_choose_snippet.webp?v=c010dff0\" alt=\"The WPCode block settings panel in the WordPress editor sidebar, with a red arrow pointing at the Choose snippet dropdown set to Book Review Callout\" \/><\/p>\n<p>Below that sits an <strong>Attributes<\/strong> panel holding one field per registered attribute, each labeled with the attribute name. Next, type each value into its own field.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_14_attribute_fields.webp?v=6a8bd391\" alt=\"The Attributes panel of the WPCode block showing a book_title field holding Around the World in Eighty Days and a book_author field holding Jules Verne, with a red arrow pointing at the first field\" \/><\/p>\n<p>Behind the scenes the block builds the same shortcode from those fields, so what your visitors see is identical either way.<\/p>\n<h2 id=\"checking-the-result-on-your-site\">Checking the Result on Your Site<\/h2>\n<p>The last step is to see the snippet render for your visitors.<\/p>\n<p>When your values are in place, click <strong>Save<\/strong> at the top of the editor.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_15_publish_page.webp?v=14f9806c\" alt=\"The top of the WordPress page editor for a page called Book Reviews, with a red arrow pointing at the Save button\" \/><\/p>\n<p>Now open the page on the front end of your site. Where the snippet sat, it renders with the values you passed in, and any attribute you left out simply comes through empty.<\/p>\n<p><img decoding=\"async\" style=\"display:block;margin:1.5rem auto\" class=\"aligncenter\" src=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2026\/10\/wpcode-shortcode-attributes-step_16_rendered_output.webp?v=d94a3255\" alt=\"A published WordPress page titled Book Reviews showing the rendered snippet as a bordered card reading Around the World in Eighty Days by Jules Verne\" \/><\/p>\n<p>To reuse the snippet elsewhere, place it again with different values. One snippet, as many variations as you need.<\/p>\n<p>That&#8217;s it! Your snippet now takes its content from the shortcode instead of having it hard-coded. Next, see our guide to <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/smart-tags\/\" target=\"_blank\">using smart tags in your snippets<\/a> for what else a snippet can pull in.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<p>Below, we&#8217;ve answered some of the most common questions about WPCode shortcode attributes.<\/p>\n<h3 id=\"which-characters-can-i-use-in-an-attribute-name\">Which characters can I use in an attribute name?<\/h3>\n<p>Lowercase letters, numbers, and underscores. WPCode lowercases the name and removes anything else while you type, so &#8220;Book Title&#8221; becomes <code>booktitle<\/code> and &#8220;author-name&#8221; becomes <code>authorname<\/code>. A name made up entirely of other characters leaves nothing behind, and WPCode adds no attribute.<\/p>\n<h3 id=\"which-snippet-types-can-read-attribute-values\">Which snippet types can read attribute values?<\/h3>\n<p>The two routes cover different types. Smart tags resolve in HTML, Text, JavaScript, and Universal snippets. PHP variables are available in PHP and Universal snippets. Universal snippets are the one type that supports both.<\/p>\n<p>The Smart Tags picker is hidden on CSS, Blocks, and PHP snippets, which is why PHP snippets use variables. It does stay visible on SCSS snippets, where an <code>{attr_...}<\/code> tag is left in place as written rather than swapped for a value. For styling, use a CSS or SCSS snippet, and keep the attribute values in the snippet type that renders your markup.<\/p>\n<h3 id=\"what-happens-if-i-leave-an-attribute-out-of-the-shortcode\">What happens if I leave an attribute out of the shortcode?<\/h3>\n<p>That attribute comes through as an empty value, and the rest of the snippet renders as usual. The same thing happens when an attribute name is spelled differently in the shortcode than it is in the snippet settings. WPCode reads only the names on the registered list, so the unrecognized one is ignored and the registered one stays empty.<\/p>\n<h3 id=\"do-i-need-to-put-quotes-around-attribute-values\">Do I need to put quotes around attribute values?<\/h3>\n<p>Quotes are what hold a multi-word value together. WordPress reads an unquoted value up to the first space. That means <code>book_title=Around the World<\/code> passes through as &#8220;Around&#8221; on its own, while <code>book_title=\"Around the World\"<\/code> passes the whole title.<\/p>\n<h3 id=\"can-i-pass-text-between-opening-and-closing-shortcode-tags\">Can I pass text between opening and closing shortcode tags?<\/h3>\n<p>Yes. Wrap your text in a matching pair of tags, as in <code>[[wpcode id=\"512\"]]Some quoted text[[\/wpcode]]<\/code>. WPCode makes that text available as the <code>content<\/code> attribute without your registering anything. In a smart tag snippet, use it as <code>{attr_content}<\/code>. In a PHP snippet, it arrives as <code>$content<\/code>, which is set for shortcodes that enclose text.<\/p>\n<h3 id=\"does-the-snippet-need-to-be-active-for-the-shortcode-to-work\">Does the snippet need to be active for the shortcode to work?<\/h3>\n<p>Yes. WPCode checks the snippet&#8217;s status before it renders anything, so set the status toggle at the top of the editor to <strong>Active<\/strong> and save. Any <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/how-to-use-snippets-smart-conditional-logic\/\" target=\"_blank\">conditional logic rules<\/a> on the snippet are checked at the same point and also have to be met.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Would you like one snippet to show different text everywhere you place it? In this guide, we&#8217;ll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you&#8217;d like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags [&hellip;]<\/p>\n","protected":false},"author":2,"template":"","class_list":["post-2085","wpcode_doc","type-wpcode_doc","status-publish","hentry","wpcode_doc_category-functionality"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO Pro 5.0.5 - aioseo.com -->\n\t<meta name=\"description\" content=\"Would you like one snippet to show different text everywhere you place it? In this guide, we&#039;ll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you&#039;d like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Mircea Sandu\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO Pro (AIOSEO) 5.0.5\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"WPCode - The Best WordPress Code Snippets Plugin\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Using Shortcode Attributes - WPCode\" \/>\n\t\t<meta property=\"og:description\" content=\"Would you like one snippet to show different text everywhere you place it? In this guide, we&#039;ll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you&#039;d like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr\" \/>\n\t\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2023-05-30T09:33:57+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-10-05T13:49:01+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Using Shortcode Attributes - WPCode\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Would you like one snippet to show different text everywhere you place it? In this guide, we&#039;ll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you&#039;d like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr\" \/>\n\t\t<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t\t<meta name=\"twitter:data1\" content=\"Mircea Sandu\" \/>\n\t\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpcode.com\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/#listItem\",\"name\":\"Docs\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/#listItem\",\"position\":2,\"name\":\"Docs\",\"item\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/categories\\\/docs\\\/functionality\\\/#listItem\",\"name\":\"Functionality\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/categories\\\/docs\\\/functionality\\\/#listItem\",\"position\":3,\"name\":\"Functionality\",\"item\":\"https:\\\/\\\/wpcode.com\\\/categories\\\/docs\\\/functionality\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#listItem\",\"name\":\"Using Shortcode Attributes\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/#listItem\",\"name\":\"Docs\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#listItem\",\"position\":4,\"name\":\"Using Shortcode Attributes\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/categories\\\/docs\\\/functionality\\\/#listItem\",\"name\":\"Functionality\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/#organization\",\"name\":\"WPCode\",\"description\":\"The Best WordPress Code Snippets Plugin\",\"url\":\"https:\\\/\\\/wpcode.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/wpcode.com\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/logo-wpcode.svg?wsr\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#organizationLogo\"},\"image\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/author\\\/msanduawesomemotive-com\\\/#author\",\"url\":\"https:\\\/\\\/wpcode.com\\\/author\\\/msanduawesomemotive-com\\\/\",\"name\":\"Mircea Sandu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/858afa2a871931eea37bc916f2608b8af2e53953f981b2c8cc72cac52b5570ea?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Mircea Sandu\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#webpage\",\"url\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/\",\"name\":\"Using Shortcode Attributes - WPCode\",\"description\":\"Would you like one snippet to show different text everywhere you place it? In this guide, we'll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you'd like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/docs\\\/shortcode-attributes\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/author\\\/msanduawesomemotive-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/author\\\/msanduawesomemotive-com\\\/#author\"},\"datePublished\":\"2023-05-30T09:33:57-04:00\",\"dateModified\":\"2026-10-05T09:49:01-04:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpcode.com\\\/#website\",\"url\":\"https:\\\/\\\/wpcode.com\\\/\",\"name\":\"WPCode\",\"description\":\"The Best WordPress Code Snippets Plugin\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpcode.com\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO Pro -->\r\n\t\t<title>Using Shortcode Attributes - WPCode<\/title>\n\n","aioseo_head_json":{"title":"Using Shortcode Attributes - WPCode","description":"Would you like one snippet to show different text everywhere you place it? In this guide, we'll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you'd like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags","canonical_url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#listItem","position":1,"name":"Home","item":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/","nextItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/#listItem","name":"Docs"}},{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/#listItem","position":2,"name":"Docs","item":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/","nextItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/#listItem","name":"Functionality"},"previousItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/#listItem","position":3,"name":"Functionality","item":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/","nextItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#listItem","name":"Using Shortcode Attributes"},"previousItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/#listItem","name":"Docs"}},{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#listItem","position":4,"name":"Using Shortcode Attributes","previousItem":{"@type":"ListItem","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/#listItem","name":"Functionality"}}]},{"@type":"Organization","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#organization","name":"WPCode","description":"The Best WordPress Code Snippets Plugin","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/","logo":{"@type":"ImageObject","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2022\/11\/logo-wpcode.svg?wsr","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#organizationLogo"},"image":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/author\/msanduawesomemotive-com\/#author","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/author\/msanduawesomemotive-com\/","name":"Mircea Sandu","image":{"@type":"ImageObject","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#authorImage","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/secure.gravatar.com\/avatar\/858afa2a871931eea37bc916f2608b8af2e53953f981b2c8cc72cac52b5570ea?s=96&d=mm&r=g","width":96,"height":96,"caption":"Mircea Sandu"}},{"@type":"WebPage","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#webpage","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/","name":"Using Shortcode Attributes - WPCode","description":"Would you like one snippet to show different text everywhere you place it? In this guide, we'll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you'd like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#website"},"breadcrumb":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/#breadcrumblist"},"author":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/author\/msanduawesomemotive-com\/#author"},"creator":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/author\/msanduawesomemotive-com\/#author"},"datePublished":"2023-05-30T09:33:57-04:00","dateModified":"2026-10-05T09:49:01-04:00"},{"@type":"WebSite","@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#website","url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/","name":"WPCode","description":"The Best WordPress Code Snippets Plugin","inLanguage":"en-US","publisher":{"@id":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/#organization"}}]},"og:locale":"en_US","og:site_name":"WPCode - The Best WordPress Code Snippets Plugin","og:type":"article","og:title":"Using Shortcode Attributes - WPCode","og:description":"Would you like one snippet to show different text everywhere you place it? In this guide, we'll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you'd like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags","og:url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/","og:image":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr","og:image:secure_url":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr","og:image:width":2400,"og:image:height":1260,"article:published_time":"2023-05-30T09:33:57+00:00","article:modified_time":"2026-10-05T13:49:01+00:00","twitter:card":"summary_large_image","twitter:title":"Using Shortcode Attributes - WPCode","twitter:description":"Would you like one snippet to show different text everywhere you place it? In this guide, we'll walk you through registering shortcode attributes on a WPCode snippet and reading the values you pass in. All you need is WPCode and a snippet you'd like to reuse. Registering Shortcode Attributes Inserting Attribute Values with Smart Tags","twitter:image":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-content\/uploads\/2023\/08\/wpcode-featured-image-2.jpg?wsr","twitter:label1":"Written by","twitter:data1":"Mircea Sandu","twitter:label2":"Est. reading time","twitter:data2":"8 minutes"},"aioseo_meta_data":{"post_id":"2085","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"WebPage","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"seo_analyzer_scan_date":"2026-10-05 13:49:19","breadcrumb_settings":null,"limit_modified_date":false,"open_ai":"{\"title\":{\"suggestions\":[],\"usage\":0},\"description\":{\"suggestions\":[],\"usage\":0}}","ai":null,"created":"2023-05-29 11:36:41","updated":"2026-10-09 09:39:07","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/\" title=\"Home\">Home<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/\" title=\"Docs\">Docs<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/\" title=\"Functionality\">Functionality<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\tUsing Shortcode Attributes\n<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/"},{"label":"Docs","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/"},{"label":"Functionality","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/categories\/docs\/functionality\/"},{"label":"Using Shortcode Attributes","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/docs\/shortcode-attributes\/"}],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/wpcode_doc\/2085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/wpcode_doc"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/types\/wpcode_doc"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/users\/2"}],"version-history":[{"count":6,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/wpcode_doc\/2085\/revisions"}],"predecessor-version":[{"id":7306,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/wpcode_doc\/2085\/revisions\/7306"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/wpcode.com\/wp-json\/wp\/v2\/media?parent=2085"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}