WordPress shortcodes: How to insert shortcodes in WordPress

WordPress shortcodes. Have you ever noticed a text within brackets in WordPress? Then you have seen a shortcode. Shortcodes 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 WordPress.

What are shortcodes?

Have you ever noticed a text within brackets in WordPress? Then you have seen a shortcode. Shortcodes in WordPress are:

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

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

[Active24-shortcode].

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

When to use shortcodes in WordPress

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

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

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

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

Such dynamic content would need a lot of code to be written. Shortcodes simplify the process of adding features to a WordPress website. They add HTML and other dynamic mark-up languages to the post, page, widget or comment. Wherever the WordPress user wants them to appear. On 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. However, if you 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 shortcodes in several ways:

1. Inbuilt shortcodes

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

TIP: Often WordPress users do not know which shortcodes are available already. To find out, use the shortcode reference plugin. It provides a detailed list of available shortcodes on 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 shortcodes. 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 plugins.

 

Shortcode ultimate plugin ukázka

After installation:

  • Log in to WordPress Dashboard.
  • Click Insert Shortcode.
  • Choose the shortcode ofyour choice.

 

These shortcodes remain functioning after changing the WordPress template.

How to insert shortcodes in WordPress

You can insert shortcodes in WordPress into:

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

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

1. Insert Shortcodes into a 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 shortcode 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 into WordPress Pages

To insert shortcodes into WordPress pages:

If you want to use shortcodes 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 into WordPress Widgets.

To use shortcodes 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 into 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 shortcode 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 a 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 visitors will see the graphical table.

 

Article rating

Average rating: 4.6/5

Votes: 13