How to create your own WordPress shortcode

Added below code to your function.php file of your active child theme (or theme).

add_shortcode('display_shortcode','my_shortcode');
function my_shortcode()
{
 echo "hello world"; // write here your html code what ever you display
}
  • Added below code in your php file where you display this shortcode:
  • 
    

    or

  • Added below code if you want to use this shorcode in your widget:
  • [display_shortcode]
    

Leave a Comment

Scroll to Top