How to create shortcode in wordpress?

Step 1.  Create PHP File shortcode.php. Insert Following code in file
<?php
add_shortcode('video_emb', 'video_emb');

function video_emb($atts){
    $atts = shortcode_atts(array(
        'src'=>'',
        'height'=>'388',
        'width'=>'600',
        'title'=>''
    ), $atts);   
    echo '
        <div id="tutorial_image">
            <iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="' . $atts['src'] . '" frameborder="0" allowfullscreen></iframe>
            <h4>' . $atts['title'] . '</h4>
        </div>
    ';
}
?>


Step 2.
Include this file in function.php on top.



Try out shortcode in POST.


[video_emb src="c:\fdsf.avi"]

Most Popular

Connect to Amazon EC2 instance using Filezilla and SFTP

Pan Card Validation Using Javascript

Customize wordpress register form wp_register()