PressTigers

Playing with Shortcodes in WordPress

Shortcode is the handiest feature of WordPress launched in its version 2.5. A small and special piece of code enclosed in the square brackets (for example [Hello_PressTigers]) can do wonders. Whenever you use a shortcode, there is a functionality behind that tiny code which will be rendered on your website.

It’s manipulation is very straightforward. Let’s assume that you want to display posts on your website with a post format “gallery“.  All you need to do is place the following code where you want to display those particular posts:

[gallery]

While placing the above mentioned shortcode, you will be able to see those particular posts (with gallery post format) rendered on your website. Additionally, you can pass different attributes to that shortcode like below:

[gallery id="123" size="medium"]

The above shortcode will display the post that have an ID equal to 123 and is medium in size. The gallery shortcode is a predefined shortcode of WordPress. WordPress provides us many shortcodes by default which are listed below:

    • [audio]
    • [caption]
    • [gallery]
    • [playlist]
    • [video]

    If you want to create your own custom shortcode (For example: To display Google Direction Map on your website), you can read and follow the steps mentioned in our article.

    You can also generate your own custom shortcode without writing the code from scratch. For this, you can use the  Generate Shortcode platform.

    User Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

      Get in Touch