This article describes how to create and use custom shortcodes in WordPress.
Shortcodes are useful when you have to add dynamic or repeatable content to multiple areas of a WordPress site. By editing a shortcode, you can quickly change content in multiple areas of your site simultaneously, instead of editing multiple pages individually.
To create and use a shortcode in WordPress, follow these steps:
Copy the following code snippet and then paste it at the bottom of the functions.php file:
function custom_shortcode() { // Change $message to the text you want to display: $message = 'Here is the shortcode text.'; return $message; } add_shortcode('my_custom_shortcode', 'custom_shortcode');
The shortcode is now enabled. To use it, open a post or page on the site, and then type [my_custom_shortcode] where you want to display the shortcode message text. For example:
Save your changes, and then view the post:
For more information about shortcodes in WordPress, please visit https://wordpress.com/support/shortcodes.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.