Create your first Shortcode in WordPress

WordPress provides awesome shortcode functionality. The shortcode is the simple set of the function used in WordPress post or pages. The shortcode enables Theme/Plugin developer to display special kind of content like Form, Menu, Listing, Recent Posts, Tags, Category, Related Posts etc… So, The shortcode is very useful for WordPress developer. let’s see how to create your first Shortcode in WordPress.

The shortcode is very helpful for display video and audio file on the WordPress post and page. let’s see how to create the first shortcode on WordPress.

function thecodingstuff_shortcode( $atts ) {
    $a = shortcode_atts( array(
        'name' => 'thecodingstuff',
    ), $atts );

    return "Welcome ".$a['name'];
add_shortcode( 'thecodingstuff', 'thecodingstuff_shortcode' );

our shortcode is ready for used. let’s see how we can use this shortcode. there are two ways to used above shortcode like

[thecodingstuff name="Saroj"]


<?php print do_shortcode('[thecodingstuff name="Saroj"]'); ?>

The output for above shortcode is the “Welcome Saroj”

If you face any problem or have a question write the comment below.


Published by


Hello there, I am developer currently working with the company at Pune and part-time freelancer. Always I welcome a new opportunity.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s