How to Create Custom Shortcode for WordPress

This is how you create Shortcode in WordPress from the function.php

// [bartag foo="foo-value"]
function bartag_func( $atts ) {
    $a = shortcode_atts( array(
        'foo' => 'something',
        'bar' => 'something else',
    ), $atts );

    return "foo = {$a['foo']}";
}
add_shortcode( 'bartag', 'bartag_func' );

//Show the short code in the site
[bartag foo="bar" bar="bing"]