Sometimes, no matter how cool your theme or how incredible the visual editing plugin you are using is, there is a feature you want that they just don’t have. And the easiest way to add some really cool functionality into your site is with a shortcode.
custom_plugin.php
function shortcode_fun(){
return 'this is custom shortcode';
}
add_shortcode('sc', 'shortcode_fun');
shortcode [sc] // paste in any page OR<?php
echo
do_shortcode(
"[your_shortcode]"
); ?>
function certificate_form_generate_fun(){
return
'<form action="" method="post">
<input type="text" id="name" name="name">
<input type="text" id="email" name="email">
<button id="newsubmit" name="submit" type="submit">Save</button>
</form>';
}
add_shortcode('certificate_form', 'certificate_form_generate_fun');
function my_shortcode_fun($atts){ $atts = array_change_key_case($atts, CASE_LOWER); // for manage case sensitive $atts = shortcode_atts(['msg' => 'include("abc.php")'], $atts); // return a value should be equal to $atts return "Hi this is my shortcode ".$atts['msg']; } add_shortcode('my_shortcode', 'my_shortcode_fun');
[my_shortcode msg="hi pankaj"] // Hi this is my shortcode hi pankaj [my_shortcode] // Hi this is my shortcode hello pankaj [my_shortcode MsG="check case"] // Hi this is my shortcode check case (its working)