WordPress shortcodes: how to insert shortcodes in WordPress?

WordPress shortcodes. Did you ever see a text within brackets in WordPress? Then you have seen a shortcode. Shortcuts add new features to your content and ease your work. Want to add a video, button or survey without using a code? WordPress shortcodes: how to insert shortcodes in

What are shortcodes?

Did you ever see a text within brackets in WordPress? Then you have seen a short code. Shortcodes in WordPress are:

bits of small code that allow WordPress website users to do various things very easy. Without writing any code.”

WordPress introduced it in WordPress version 2.5. And look like this:

[Active24-shortcode].

You can enter the special tags in several places on WordPress. It replaces the content, when a web visitor views its WordPress site.

When to use shortcodes in WordPress?

WordPress has several security checks and filters built in.
To prevent malicious code to come into:

  • WordPress Posts
  • WordPress Pages
  • WordPress Widgets
  • WordPress Themes

So, users cannot write code in such WordPress elements. Yet, WordPress short codes allow its users to add “dynamic content” inside WordPress.
Such as:

  • Insert graphics
  • Embed video files
  • Add galleries or responsive slider
  • Create macro objects
  • Create a survey form in WordPress
  • Add buttons

Such dynamic content would need writing a lot of code. Short codes simplify this process of adding features to a WordPress website. They add HTML and other dynamic markup languages. Into the post, page, widget or comment. Wherever the WordPress user wants them to appear. In one single line.

When Not to use shortcodes in WordPress?

Specific shortcodes are not needed if you only create one feature on a specific post or page. But, if you will use that shortcode in many different posts or pages, you may want to use a plugin to add a shortcode. This will make it easier to style a specific WordPress element. It is also easier to remove if you want to change Themes for example.

How are WordPress shortcodes provided?

You can provide WordPress short codes in several ways:

1. Inbuilt shortcodes

These are short codes included in the chosen WordPress Template under the content editor. Such as: “audio, caption, embed, gallery, and video”. These short code stop functioning, when you change the WordPress template.

TIP: Often WordPress users do not know which short codes are available already. To find out, use the shortcode reference plugin. It provides a detailed list of available short codes in the existing WordPress site.

2. Shortcode Ultimate Plugin

Lacking features in your WordPress editor? Then Shortcode Ultimate is a great solution. This WordPress plugin provides a free pack of versatile short codes. With this free plugin package you can insert, among others:

  • QR code generator
  • Gallery
  • Sliders
  • Responsive videos
  • Buttons with icons
  • Macro tables
  • Tabs and boxes
  • Audio
  • Google Map

This plugin prevents you having to install a dozen of plugins.

 

edit_shortcode_sk

After installation:

  • Login to WordPress Dashboard.
  • Click Insert Shortcode.
  • Chose the short code of your choice.

These short codes remain functioning after changing the WordPress template.

How to insert shortcodes in WordPress?

You can insert shortcodes in WordPress on:

  • WordPress Posts
  • WordPress Pages
  • WordPress Widgets
  • WordPress Themes

Some plugins offer the ability to paste into content through short codes. Putting the short code in the body of the Post or Page will perform its function.

1. Insert Short codes in WordPress Post

To insert shortcodes into a WordPress post:

  • Log in to the WordPress Dashboard with your login details.
  • In the navigation menu, click “Post
  • Click the post you want to edit.
  • Click “Text”.
  • Insert shortcode.
  • Click “Update” to save your changes.

TIP: To use the text of a short code in a WordPress post, avoid using double brackets. Yet, if you want the text of the video shortcode to display rather than the actual video you can add: .

2. Insert shortcode in WordPress Pages

To insert shortcodes in WordPress pages:

If you want to use short codes in places other than content, you need to add a text widget first. Second, insert a shortcode into the WordPress Widgets Sidebar or WordPress Templates:

3. Insert Shortcodes in WordPress Widgets.

To use short codes inside your WordPress Widgets sidebar:

  • Log in to the WordPress Dashboard with your login details.
  • In the navigation menu, click “Pages
  • Click the Page you want to edit.
  • Click “Text
  • Add shortcode.
  • Click “Update” to save your changes.

    Now you can insert shortcuts into a text widget as well as content.

    TIP: Remember, this feature is not enabled by default in WordPress. If you can not see your shortcode in a widget, then you need to add the above code in your theme’s functions.php file.

    4. Insert shortcodes in WordPress Templates (advanced)

    Find a shortcode in WordPress theme

    Here’s an example of what a shortcode looks like:

    • Log in to the WordPress Dashboard with your login details.
    • Drag and drop a text widget to your sidebar
    • Make a small code modification in the functions.php file.
    • At the end of the file, paste Add_filter ("widget_text", "do_shortcode");
    • Add your short code of choice inside it.
    • And Save changes.
      • Open the Theme's folder. Go to:
        “/wp-content/themes/your-theme-name/”
      • Open the functions.php file or if the theme has an included folder, inside that folder.
      • Open the files and search for the term add_shortcode.

    • function my_shortcode_function() { $i = '

      Hello World!

      '; return $i; } add_shortcode('my-shortcode', 'my_shortcode_function');
       

      To create an advanced Macro Table

      • Open the Theme's folder. Go to:
        “/wp-content/themes/your-theme-name/”
      • Generate a new HTML-table in the Plugin settings.
      • Assign a unique short code to the table: [supsystic-tables id = 10].
      • Select the post or page, where you want to insert the table.
      • Place the shortcode.
      • Click Save to Save your changes.
       

      It is possible to use the shortcode in a non-widget area of your theme as well. Add the following PHP function where you want to display the code:

      [example_shortcode]
      OF
      Echo do_shortcode ("[select_shortcode]");

      TIP: In the WordPress editor, the added code in the text box is still displayed. You will not see the Table, but the code that calls up the table, when viewed by the user. Yet, your web visitor will see the graphical table.

Article rating

Average rating: 5/5

Votes: 120