Loading…

What is shortcode in WordPress? How we can use it?

Shortcodes in WordPress are specific codes that allow the developers to do various tasks with minimal effort. Shortcodes are used to simplify tasks such as creating objects or embedding files that require lots of coding in a single line. A Shortcode is synonymous to the shortcut. WordPress has five built-in shortcodes- audio, embed, caption, video, and gallery.

Example

                                        

1. You can call shortcode function like this :
echo do_shortcode('[display_related_posts]');

2. In your function.php you can make
function display_related_posts($array = array()) {
      return 'BestInterviewQuestion.com';
}
add_shortcode('display_related_posts', 'display_related_posts');

Suggest An Answer

No suggestions avaliable!

Latest post from Wordpress Interview Questions

Ask Question