How to create a WordPress shortcode?

WordPress Shortcodes allow you to extend the functionality of WordPress. Shortcodes are text within the square bracket. You can paste this shortcode on any page, post or widget. WordPress executes the PHP function associated with the shortcode and displays the result instead of the actual shortcode text. You can find more about WordPress shortcodes at

To create a shortcode, open functions.php in your theme folder, add the following code at the end of the file

Now your shortcode is ready. You can place the shortcode on any page, post, or widget by placing the following text

It will display the text Hello World from shortcode.

A shortcode is a normal PHP function, it can do more complex things like connect to MySQL database, fetch data from a remote API, do calculations, etc…

See WordPress

Need help with Linux Server or WordPress? We can help!

Leave a Reply

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