How to Use Shortcodes on WordPress

In this article, we going to see how to use shortcodes on WordPress. Shortcode is a bit of code which helps to execute the function to display the content on the website. By using do_shortcode function, we can display content or some kind of function anywhere on our WordPress website. Here below you can see the example for do_shortcode.
Example:
1 |
<?php echo do_shortcode('[your shortcode]'); ?> |
Note: Need to replace your shortcode to the plugin shortcode.
Example: Display Site Reviews Plugin Shortcode
Here I show you an example for using shortcode with Site Review Plugin.
In this example, I am going to use the review shortcode for all the post by the post id.
Shortcode:
1 |
[site_reviews_form assign_to="post_id"] |
Now I’m going to use this shortcode in single.php (Single Post) with do_shortcode function like this below example.
1 |
<?php echo do_shortcode('[site_reviews_form assign_to="post_id"]'); ?> |
Output:
Below can you see the final output for Site Reviews plugin shortcode.
Conclusion:
I hope this will helped you to use shortcodes and display in your WordPress post or page using do_shortcode function. If you like this article share it with your friends.
If you have any questions about the topic let me know in the comment box.
ShortcodeWithout Pluginwordpress
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]