Create Shortcode in Wordpress

You can create any shortcode in wordpress by using below code format

Here i am showing you an example Shortcode for "Date".

function cdate_shortcode() {
  $shortdate = get_the_date('l, F j, Y');
  return $shortdate;
}
add_shortcode('shortdate', 'cdate_shortcode');

Place the above code in your theme's function.php file

Use [shortdate] in your Posts/pages.

No comments:

Post a Comment