Step by step WordPress Shortcode 2017

How to make a WordPress Shortcode?

WordPress have a functionality that called shortcode. By using WordPress shortcode we can create a function and use it later without adding a line of PHP file. We can easily add the simple code in our content section and get our dynamic result. There are two types of major shortcode feature.

1. Self-closing Shortcode
2. Enclosing Shortcode

How to make a WordPress self-closing shortcode

Here we will learn how to make a self-closing shortcode in WordPress theme step by step. We can also use our shortcode in WordPress Must Use Plugin file. We can also use our shortcode as a plugin so that we can use that shortcode in any WordPress theme. Here I will show an example of shortcode using WordPress theme functions.php

function janealam_shortcode( $attr, $content =null){
return '<a class="facebook-button" href="">Follow me on Facebook!</a>';

Let’s test the shortcode and how it works. After adding this code in theme functions.php¬† save the file and login WordPress admin panel. Create a blank page or post and paste [my_button] on content text area publish the page or post. Open the page or post. The output of the [my_button] will show a text “Follow me on Facebook!” with a link. This self-closing WordPress shortcode used for the button, social-link also for dynamic output of a page, post or custom post types.

Next articles for WordPress shortcode enclosing…

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt
WordPress Blog, WordPress, Visual Editor, WordPress 4.7.3, WordPress Shortcode, WordPress Memory