How to create custom shortcode in WordPress?

by websourceblog ·
Published October 28, 2018
· Updated October 31, 2018

Shortcode in WordPress.

In WordPress we can create custom shortcodes and we can show its output anywhere on the site. To create a shortcode, we will use WordPress built in function add_shortcode(), this function required two parameters, first “shortcode” and others “callback function”; callback function is the function that we will create in theme’s functions.php file.

For reference, check following function, suppose there is custom post type named “movies” and you want to show movie list in sidebar.