{"id":603,"date":"2018-05-04T12:08:13","date_gmt":"2018-05-04T12:08:13","guid":{"rendered":"http:\/\/jeowebmasterservices.com\/newsite\/?p=603"},"modified":"2020-08-16T14:21:16","modified_gmt":"2020-08-16T14:21:16","slug":"what-is-shortcode-tutorial","status":"publish","type":"post","link":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/","title":{"rendered":"What the heck is a &#8220;shortcode&#8221;?"},"content":{"rendered":"<p>Have you ever wanted to add a special feature or change some layout or just customize the way your WordPress website displays to your visitors? Then you will love learning about &#8220;shortcodes&#8221;.<\/p>\n<p>Introduced in WordPress from 2.5 onward, they are &#8220;macro codes&#8221; you can place within your content &#8211; in the main content, in sidebars and widgets, where ever you need just a bit of customization to help your site stand out from all the others who are using a similar theme. This can be a great way to create a reusable dynamic ad spot or a call-to-action button in your posts.<\/p>\n<p>Examples of custom shortcodes I&#8217;ve developed for my clients include simple &#8220;call to action&#8221; buttons and a custom module that grabs the 10 next performances from a musician performances database and then display those in a unique way on the artist&#8217;s home page.<\/p>\n<p>Since shortcodes enhance the core functionality of the WordPress software, one has to know a bit about the internal file stucture of a WordPress site. Since your theme&#8217;s &#8220;functions.php&#8221; file will require a little adjustment, this brings up the issue of &#8220;where the heck to I place my shortcode code&#8221; such that it survives a software update to your theme or core WordPress itself. We&#8217;ll get to that in a minute.<\/p>\n<p>If we use the call-to-action example, you could add something like this to your blogpost to show the button, and then edit the output in your templates functions.php file, which we\u2019ll get to in a minute.<\/p>\n<pre class=\"prettyprint\">[button]<\/pre>\n<p>To customize the button, we could simply add something like:<\/p>\n<pre class=\"prettyprint\">[button type=\"twitter\"]<\/pre>\n<p>Or to make it even better, we could use an enclosing shortcode:<\/p>\n<pre class=\"prettyprint\">[button type=\"twitter\"]Follow me on Twitter![\/button]<\/pre>\n<p>With some imagination, you soon realize the potential of shortcodes, and what can be done with them. In this article, I\u2019ll show you how to create and use these three different types of shortcodes, and then I\u2019ll show off some ready-to-use shortcodes to use on your own WordPress site.<\/p>\n<h2>Creating a self-closing shortcode<\/h2>\n<p>The simplest shortcode is the self-closing one. We\u2019re going to create a simple link to our Twitter account, and then add it in a blog post.<\/p>\n<p>All the code goes in <strong>functions.php<\/strong>, which is located in <strong>\/wp-content\/themes\/your-theme\/<\/strong>. If you don\u2019t have one, just create it and put the code in it.<\/p>\n<pre class=\"prettyprint\">&lt;?php \nfunction button_shortcode() {\n    return '&lt;a href=\"http:\/\/twitter.com\/filipstefansson\" class=\"twitter-button\"&gt;Follow me on Twitter!&lt;\/a&gt;\"';\n}\nadd_shortcode('button', 'button_shortcode'); \n?&gt;<\/pre>\n<p>Usage:<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"tHt4MxEruZ\"><p><a href=\"https:\/\/speckyboy.com\/getting-started-with-wordpress-shortcodes-examples\/\">Getting Started with WordPress Shortcodes &#038; Sample Snippets<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Getting Started with WordPress Shortcodes &#038; Sample Snippets&#8221; &#8212; Speckyboy Design Magazine\" src=\"https:\/\/speckyboy.com\/getting-started-with-wordpress-shortcodes-examples\/embed\/#?secret=tHt4MxEruZ\" data-secret=\"tHt4MxEruZ\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>https:\/\/cpothemes.com\/using-wordpress-shortcodes<br \/>\nSeparating The Content Into Columns<br \/>\nThe most basic usage of shortcodes for layout is to create multiple columns. Separating the content into distinguishable blocks will make your content look more organized, and you can take advantage of this to add images or other media. As you work with columns, you will begin to see all the possibilities that open up\u2013 certain layouts are simply not doable without a column-based design. It is recommended you use from 2 to 4 columns, as it is a good balance between the number of content blocks and the available space of each block.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to add a special feature or change some layout or just customize the way your WordPress website displays to your visitors? Then you will love learning about &#8220;shortcodes&#8221;. Introduced in WordPress from 2.5 onward, they are &#8220;macro codes&#8221; you can place within your content &#8211; in the main content, in sidebars [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-603","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What the heck is a &quot;shortcode&quot;? - JEO Webmaster Services<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What the heck is a &quot;shortcode&quot;? - JEO Webmaster Services\" \/>\n<meta property=\"og:description\" content=\"Have you ever wanted to add a special feature or change some layout or just customize the way your WordPress website displays to your visitors? Then you will love learning about &#8220;shortcodes&#8221;. Introduced in WordPress from 2.5 onward, they are &#8220;macro codes&#8221; you can place within your content &#8211; in the main content, in sidebars [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"JEO Webmaster Services\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/JEOWebmasterServices\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-04T12:08:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-16T14:21:16+00:00\" \/>\n<meta name=\"author\" content=\"john.erik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JohnnieWebServe\" \/>\n<meta name=\"twitter:site\" content=\"@JohnnieWebServe\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"john.erik\" \/>\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\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\"},\"author\":{\"name\":\"john.erik\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/90e3c2b19dde1b01b81b5a8a71a05163\"},\"headline\":\"What the heck is a &#8220;shortcode&#8221;?\",\"datePublished\":\"2018-05-04T12:08:13+00:00\",\"dateModified\":\"2020-08-16T14:21:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\"},\"wordCount\":502,\"publisher\":{\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\",\"url\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\",\"name\":\"What the heck is a \\\"shortcode\\\"? - JEO Webmaster Services\",\"isPartOf\":{\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#website\"},\"datePublished\":\"2018-05-04T12:08:13+00:00\",\"dateModified\":\"2020-08-16T14:21:16+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jeowebmasterservices.com\/newsite\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What the heck is a &#8220;shortcode&#8221;?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#website\",\"url\":\"https:\/\/jeowebmasterservices.com\/newsite\/\",\"name\":\"JEO Webmaster Services\",\"description\":\"One-Stop Shop for all your webmaster needs\",\"publisher\":{\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jeowebmasterservices.com\/newsite\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#organization\",\"name\":\"JEOWebmasterServices\",\"url\":\"https:\/\/jeowebmasterservices.com\/newsite\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jeowebmasterservices.com\/newsite\/wp-content\/uploads\/2017\/02\/old-SEO-wood_boards-1400B.jpg\",\"contentUrl\":\"https:\/\/jeowebmasterservices.com\/newsite\/wp-content\/uploads\/2017\/02\/old-SEO-wood_boards-1400B.jpg\",\"width\":1400,\"height\":586,\"caption\":\"JEOWebmasterServices\"},\"image\":{\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/JEOWebmasterServices\/\",\"https:\/\/x.com\/JohnnieWebServe\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/90e3c2b19dde1b01b81b5a8a71a05163\",\"name\":\"john.erik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b9957c080ac034f9abef92708370ce74?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b9957c080ac034f9abef92708370ce74?s=96&d=mm&r=g\",\"caption\":\"john.erik\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What the heck is a \"shortcode\"? - JEO Webmaster Services","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":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"What the heck is a \"shortcode\"? - JEO Webmaster Services","og_description":"Have you ever wanted to add a special feature or change some layout or just customize the way your WordPress website displays to your visitors? Then you will love learning about &#8220;shortcodes&#8221;. Introduced in WordPress from 2.5 onward, they are &#8220;macro codes&#8221; you can place within your content &#8211; in the main content, in sidebars [&hellip;]","og_url":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/","og_site_name":"JEO Webmaster Services","article_publisher":"https:\/\/www.facebook.com\/JEOWebmasterServices\/","article_published_time":"2018-05-04T12:08:13+00:00","article_modified_time":"2020-08-16T14:21:16+00:00","author":"john.erik","twitter_card":"summary_large_image","twitter_creator":"@JohnnieWebServe","twitter_site":"@JohnnieWebServe","twitter_misc":{"Written by":"john.erik","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#article","isPartOf":{"@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/"},"author":{"name":"john.erik","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/90e3c2b19dde1b01b81b5a8a71a05163"},"headline":"What the heck is a &#8220;shortcode&#8221;?","datePublished":"2018-05-04T12:08:13+00:00","dateModified":"2020-08-16T14:21:16+00:00","mainEntityOfPage":{"@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/"},"wordCount":502,"publisher":{"@id":"https:\/\/jeowebmasterservices.com\/newsite\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/","url":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/","name":"What the heck is a \"shortcode\"? - JEO Webmaster Services","isPartOf":{"@id":"https:\/\/jeowebmasterservices.com\/newsite\/#website"},"datePublished":"2018-05-04T12:08:13+00:00","dateModified":"2020-08-16T14:21:16+00:00","breadcrumb":{"@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/jeowebmasterservices.com\/newsite\/what-is-shortcode-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jeowebmasterservices.com\/newsite\/"},{"@type":"ListItem","position":2,"name":"What the heck is a &#8220;shortcode&#8221;?"}]},{"@type":"WebSite","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#website","url":"https:\/\/jeowebmasterservices.com\/newsite\/","name":"JEO Webmaster Services","description":"One-Stop Shop for all your webmaster needs","publisher":{"@id":"https:\/\/jeowebmasterservices.com\/newsite\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jeowebmasterservices.com\/newsite\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#organization","name":"JEOWebmasterServices","url":"https:\/\/jeowebmasterservices.com\/newsite\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/logo\/image\/","url":"https:\/\/jeowebmasterservices.com\/newsite\/wp-content\/uploads\/2017\/02\/old-SEO-wood_boards-1400B.jpg","contentUrl":"https:\/\/jeowebmasterservices.com\/newsite\/wp-content\/uploads\/2017\/02\/old-SEO-wood_boards-1400B.jpg","width":1400,"height":586,"caption":"JEOWebmasterServices"},"image":{"@id":"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/JEOWebmasterServices\/","https:\/\/x.com\/JohnnieWebServe"]},{"@type":"Person","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/90e3c2b19dde1b01b81b5a8a71a05163","name":"john.erik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jeowebmasterservices.com\/newsite\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b9957c080ac034f9abef92708370ce74?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9957c080ac034f9abef92708370ce74?s=96&d=mm&r=g","caption":"john.erik"}}]}},"_links":{"self":[{"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":4,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":625,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/posts\/603\/revisions\/625"}],"wp:attachment":[{"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jeowebmasterservices.com\/newsite\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}