Create your first Shortcode in WordPress

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.