Fun with WordPress Shortcodes

Have you ever heard of shortcodes? WordPress supports many of these shortcut codey-things that work sort of like HTML. Mostly they’re used in WordPress templates but there are some that anyone can use! Yes, some of them even in your free blog.

What are WordPress.com Shortcodes?

These are snippets of code that are specific to WordPress sites that allow you to embed some interesting and useful objects into your WordPress blog. Some only work on paid accounts; other short-codes can be used by anyone.  We can find the full list of supported short-codes here..

How to Use Shortcodes

Short codes are very similar to HTML. There are “containers” for most codes, that is,  we engage the server with a beginning “container” of code and then when we’re done, we end it with an ending “container.”  In HTML, those codes begin with a “tag” (or command) that is positioned within “angle brackets” (those funny greater than and less that signs.)  So the start of a new paragraph begins with <p> and the paragraph ending is indicated by a slash and the tag, surrounded once again by angle brackets, like so: </p>.

Shortcodes start and end with square brackets or [ shortcode here].   They often are ended with the slash mark, followed by the shortcode, similar to HTML codes.  We write them straight on the webpage in the editor.  Some of them work on either the blue (Jetpack) or black (WP Admin) editors.  Others require the black WP dashboard and a Premium or Business account–but some of the easiest and most useful work with any WordPress account.

Some Useful Shortcodes for Bloggers

  1. An email subscription box!    This is a neat bit of code that pops up a box that automatically emails subscribers with new content.  It’s probably the simplest form and the easiest to implement.
  2. Create a quiz! The quiz code could be a fun way to interact with your readers. A quiz on fashion for a fashion blog. A celebrity quiz or something about kittens! You know all those silly quizzes people take all the time–what house at Hogwarts do you belong to? That sort of thing? This shortcode enables you do create just those sorts of things.
    And the walkthrough is thorough and easy.
  3. Create a poll.   You have to use the black dashboard for this,  but it’s fairly easy.  It backs up to the Polldaddy platform, a popular poll creation service. WordPress provides a good walkthrough, but it doesn’t work until you’ve visited the Polldaddy.com website at least once and logged in with your WordPress credentials.   After that, it still needs a little tweaking.
  4. Create a gallery.  Many themes have built-in “hooks” for these photo galleries and photo slideshows but you can create your own pages just by embedding the codes into a post.  The post about galleries is quite long, including a short video overview– but it’s very thorough.
  5. Create a slideshow.   This might be good for products, steps in a DIY project, or any kind of presentation.
  6. Monetize with a Payment Button (for Premium and Business Plan sites). 
    ‘Say what?!
    Yes, there is an easy way to embed the capability to accept Paypal, debit and credit card payments in your site. Your site has to be public (not private)–and you have to have a Premium or Business Plan.

The Email Subscription Box Example

You can’t get any easier than the WordPress directions for implementing this bit of code. 

  1. Open your Page or Post editor
  2. Make sure you’re using the Visual tab
  3. Type or paste the code [ blog_subscription_form ] where you want the form to go. ( I’ve added an extra space before and after the code in this example here, so that the code doesn’t ACTUALLY activate in the middle of this post. Hopefully).
  4. Save the draft, or update, or publish

The Recipe Shortcode Code

If you’re a food blogger, one of the most useful shortcodes exists just for creating recipes that are easily searchable by Google, Bing and other search engines. It’s a good example of the ins and outs of shortcode.

Recipe shortcode resides between two containers,
[ recipe ]and then to end it [ /recipe ]

There are lots of attributes, that is, specifications that you can add to the code like the title of the recipe, the number of servings, time, provide an image, descriptions, etc.

There are also some extra formatting elements, to call out notes for the recipe, separate out the ingredients and the directions. WordPress has a great example for this shortcode. I’m throwing a screen-grab of the code and its results here:

and the results (partial) here:

Really, I don’t think I can do a better walk through for shortcodes than this one.  It’s all here, how to start them, how to deal with attributes, and how to deal with the special elements, like notes, ingredients and directions. Other shortcodes are very similar in that they too, have containers, special attributes and occasionally special elements.

Creating a Poll with Polldaddy

The polling capability looked dead easy but it’s clear that the instructions are a bit dated.  In order to incorporate a poll, I had to go out, find the Polldaddy site, log in and approve the connection to WordPress.  But I never got a “insert poll” option the way the instructions describe.  Instead I had to log in to Polldaddy, create the poll, then find the WordPress Shortcode.  (Don’t use the first option, Javascript–there’s another tab for the WordPress Shortcode.

And then the next screen designs what the poll looks like:

And then you’ll get the choices such as this one to embed the code. Choose the WordPress tab to get the shortcode.

And voila:

 

Thanks for visiting!  Hope this was interesting and useful!  Best, Lola

Author: Lola

Recovering academic, real-life, honest to cornflakes anthropologist (Ph.D. and fieldwork and everything), tech-head and social media researcher.

One thought on “Fun with WordPress Shortcodes

Leave a Reply