HOME / BLOG / BLOG-POST

How to create a short code in wordpress?

Create a short code in wordpress

function my_shortcode()
{
 //buffering
 //Object Start
 ob_start();
 
 date_default_timezone_set('asia/kolkata');
 
 //echo date('H:i:s');
 
 echo '<div id="mytime"></div>';
 
 // object get contents
 $output_string = ob_get_contents();
 // clean object
 ob_end_clean();
 return $output_string;
 
}
add_shortcode("clock","my_shortcode");

 


about authors

Sandip Das

Web Developer

Once a legend said “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler.



POST COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *