{"id":2237,"date":"2021-07-02T08:15:16","date_gmt":"2021-07-02T00:15:16","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2237"},"modified":"2021-07-02T08:15:19","modified_gmt":"2021-07-02T00:15:19","slug":"add-blank-wordpress-shortcode","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/add-blank-wordpress-shortcode\/","title":{"rendered":"How To Add A Blank WordPress Shortcode"},"content":{"rendered":"\n

Sometimes when you're building a site you know you're going to add particular functionality later, but you don't want to delay launching the site while you build that functionality.<\/p>\n\n\n\n

You know exactly where it needs to go, and you're going to use a shortcode to hook it in, but you don't want to leave the shortcode sitting out there.<\/p>\n\n\n\n

The solution is to build it as you would if the shortcode was available and add a blank shortcode.<\/p>\n\n\n\n

The code is as follows:<\/p>\n\n\n\n

add_shortcode( 'iw_custom_cta', 'display_iw_custom_cta' );\nfunction display_iw_custom_cta() {\n  return '';\n}<\/code><\/pre>\n\n\n\n

Let's dive into what's going on.<\/p>\n\n\n\n

How it works<\/h2>\n\n\n\n

If you add a shortcode in the usual way, you'd add a WordPress shortcode block.<\/p>\n\n\n\n

\"screenshot<\/figure><\/div>\n\n\n\n

Then add your shortcode wrapped in square brackets. In this case, the shortcode I'm adding is [iw_custom_cta]<\/em>.<\/p>\n\n\n\n

You could add this anywhere on the site, like in a widget, a page builder or in the Classic editor. I'm just using the Gutenberg editor for this example.<\/p>\n\n\n\n

\"screenshot<\/figure><\/div>\n\n\n\n

But when you publish the page, it shows [iw_custom_cta]<\/em> as plaintext.<\/p>\n\n\n\n

\"published<\/figure><\/div>\n\n\n\n

To hide that, we add the code to the functions.php<\/em> of our child theme (see how to setup your own child theme<\/a> if you need).<\/p>\n\n\n\n

add_shortcode( 'iw_custom_cta', 'display_iw_custom_cta' );\nfunction display_iw_custom_cta() {\n  return '';\n}<\/code><\/pre>\n\n\n\n

Notice that the first argument of add_shortcode()<\/em> matches what you put as the shortcode.<\/p>\n\n\n\n

You can change your shortcode to whatever you want, but I always like to put a few letters in front just to make sure it's not going to clash with anything else I'm doing or plugins I've installed.<\/p>\n\n\n\n

Then you match the second argument of add_shortcode()<\/em> to the function name and return an empty string.<\/p>\n\n\n\n

Don't return true or return false or your post will display a 1 or a 0 respectively.<\/p>\n\n\n\n

Once you've added the code to your functions.php<\/em> file as shown:<\/p>\n\n\n\n

\"WordPress<\/figure><\/div>\n\n\n\n

Your shortcode text will disappear:<\/p>\n\n\n\n

\"Front<\/figure><\/div>\n\n\n\n

When you're ready to add your functionality later, just put it inside the function and return what you need.<\/p>\n\n\n\n

You can add as many of these as you need.<\/p>\n","protected":false},"excerpt":{"rendered":"

Sometimes when you’re building a site you know you’re going to add particular functionality later, but you don’t want to delay launching the site while you build that functionality. You know exactly where it needs to go, and you’re going to use a shortcode to hook it in, but you don’t want to leave the<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"yoast_head":"\nHow To Add A Blank WordPress Shortcode<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Add A Blank WordPress Shortcode\" \/>\n<meta property=\"og:description\" content=\"Sometimes when you're building a site you know you're going to add particular functionality later, but you don't want to delay launching the site while you build that functionality. You know exactly where it needs to go, and you're going to use a shortcode to hook it in, but you don't want to leave the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\" \/>\n<meta property=\"og:site_name\" content=\"Intelliwolf\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-02T00:15:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-02T00:15:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png\" \/>\n<meta name=\"author\" content=\"Mike Haydon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Haydon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\"},\"author\":{\"name\":\"Mike Haydon\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\"},\"headline\":\"How To Add A Blank WordPress Shortcode\",\"datePublished\":\"2021-07-02T00:15:16+00:00\",\"dateModified\":\"2021-07-02T00:15:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\"},\"wordCount\":333,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png\",\"articleSection\":[\"Theme Customization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\",\"url\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\",\"name\":\"How To Add A Blank WordPress Shortcode\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png\",\"datePublished\":\"2021-07-02T00:15:16+00:00\",\"dateModified\":\"2021-07-02T00:15:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png\",\"width\":518,\"height\":244},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.intelliwolf.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Theme Customization\",\"item\":\"https:\/\/www.intelliwolf.com\/category\/theme-customization\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How To Add A Blank WordPress Shortcode\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.intelliwolf.com\/#website\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"name\":\"Intelliwolf\",\"description\":\"WordPress, Web Design and Coding Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.intelliwolf.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\",\"name\":\"Intelliwolf\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"width\":300,\"height\":100,\"caption\":\"Intelliwolf\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\",\"name\":\"Mike Haydon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"caption\":\"Mike Haydon\"},\"sameAs\":[\"https:\/\/intelliwolf.com\/about-mike-haydon\/\"]}]}<\/script>\n","yoast_head_json":{"title":"How To Add A Blank WordPress Shortcode","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/","og_locale":"en_US","og_type":"article","og_title":"How To Add A Blank WordPress Shortcode","og_description":"Sometimes when you're building a site you know you're going to add particular functionality later, but you don't want to delay launching the site while you build that functionality. You know exactly where it needs to go, and you're going to use a shortcode to hook it in, but you don't want to leave the","og_url":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/","og_site_name":"Intelliwolf","article_published_time":"2021-07-02T00:15:16+00:00","article_modified_time":"2021-07-02T00:15:19+00:00","og_image":[{"url":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png"}],"author":"Mike Haydon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mike Haydon","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#article","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/"},"author":{"name":"Mike Haydon","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343"},"headline":"How To Add A Blank WordPress Shortcode","datePublished":"2021-07-02T00:15:16+00:00","dateModified":"2021-07-02T00:15:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/"},"wordCount":333,"commentCount":0,"publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png","articleSection":["Theme Customization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/","url":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/","name":"How To Add A Blank WordPress Shortcode","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png","datePublished":"2021-07-02T00:15:16+00:00","dateModified":"2021-07-02T00:15:19+00:00","breadcrumb":{"@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#primaryimage","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-02-blank-shortcode-01.png","width":518,"height":244},{"@type":"BreadcrumbList","@id":"https:\/\/www.intelliwolf.com\/add-blank-wordpress-shortcode\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.intelliwolf.com\/"},{"@type":"ListItem","position":2,"name":"Theme Customization","item":"https:\/\/www.intelliwolf.com\/category\/theme-customization\/"},{"@type":"ListItem","position":3,"name":"How To Add A Blank WordPress Shortcode"}]},{"@type":"WebSite","@id":"https:\/\/www.intelliwolf.com\/#website","url":"https:\/\/www.intelliwolf.com\/","name":"Intelliwolf","description":"WordPress, Web Design and Coding Tutorials","publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.intelliwolf.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.intelliwolf.com\/#organization","name":"Intelliwolf","url":"https:\/\/www.intelliwolf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","width":300,"height":100,"caption":"Intelliwolf"},"image":{"@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343","name":"Mike Haydon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","caption":"Mike Haydon"},"sameAs":["https:\/\/intelliwolf.com\/about-mike-haydon\/"]}]}},"_links":{"self":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2237"}],"collection":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/comments?post=2237"}],"version-history":[{"count":1,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2237\/revisions"}],"predecessor-version":[{"id":2251,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2237\/revisions\/2251"}],"wp:attachment":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/media?parent=2237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/categories?post=2237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/tags?post=2237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}