Learn step-by-step how to create a WordPress shortcode. Start your WordPress website with Hostinger web hosting 👉 bit.ly/3uazx8b
💥 Use the discount code WP10 to get 10% OFF!
This WordPress shortcode tutorial demonstrates all the steps to create a shortcode in your WordPress website. All the necessary code snippets are available in the description below – note that the process requires some coding knowledge.
____________________________________________
___________________________________________
📌 Handy links
How to Create a Shortcode in WordPress (In 7 Steps): www.hostinger.com/tutorials/create-a-shortcode-in-…
____________________________________________
⭐ Follow Us ⭐
TikTok: www.tiktok.com/@hostingeracademy
Twitter: twitter.com/Hostinger
Facebook: www.facebook.com/Hostinger/
WordPress Explained Group: www.facebook.com/groups/wpexplained
Hostinger Tutorials: www.hostinger.com/tutorials
Subscribe to our channel: youtube.com/c/HostingerAcademy?sub_confirmation=1
____________________________________________
🕒 Timestamps
00:00 - Intro
00:11 - What is WordPress shortcode
01:21 - Creating a shortcode function
03:06 - Adding shortcode functionality
04:12 - Creating an enclosing shortcode
04:35 - Outro
___________________________________________
A WordPress shortcode is a small piece of PHP code that allows you to quickly add elements to your website’s page and post.
There are six default WordPress shortcodes:
👉 Audio
👉 Playlist
👉 Gallery
👉 Video
👉 Embed
👉 Caption
However, you can also create new shortcodes to help you publish articles faster and more efficiently. So, let’s see how to create a custom WordPress shortcode.
1️⃣ Create a New Theme File
👉 Access a File Manager or FTP client and create a custom-shortcodes.php file inside your theme’s directory. Add the necessary block of code.
👉 Save changes and delete the local file option. Then, add the code at the bottom of the functions.php file.
2️⃣ Create the Shortcode Function
👉 Open the custom-shortcode.php file and insert the desired action. In this video, we’re adding social media links to a post.
Right after that, add a callback function so WordPress knows the action is a shortcode:
3️⃣ Test the Custom Shortcode
👉 Create a new post on your WordPress website and insert the custom shortcode:
[subscribe]
4️⃣ Add Parameters to the WordPress Shortcode
👉 Open the custom-shortcodes.php file and add a code snippet so that you can customize the links within the shortcode tag.
5️⃣ Test the Parameters
👉 Let’s test the parameters by adding the shortcodes to your WordPress post.
6️⃣ Create an Enclosing WordPress Shortcode
👉 Open your custom-shortcode.php file and add the necessary lines of code
7️⃣ Add the Enclosing Shortcode to the Website
👉 For the Facebook anchor text:
[subscribe link='www.facebook.com/Hostinger/']Facebook[/subscribe]
👉 For the Twitter anchor text:
[subscribe link='twitter.com/Hostinger?s=20/']Twitter[/subscribe]
Watch our WordPress shortcode tutorial to see the shortcode’s final result. If you would like to check out the exact code snippets we used, visit the tutorial How to Create a Shortcode in WordPress: www.hostinger.com/tutorials/create-a-shortcode-in-…
________________________________________
▶ Want to see more awesome tutorials like this one in the future? Consider subscribing 😁
youtube.com/c/HostingerAcademy?sub_confirmation=1
▶ If you have questions, don’t hesitate and join our Facebook group for more help:
www.facebook.com/groups/wpexplained
____________________________________________
Thank you for watching! Let us know in the comments below if you have any questions. Good luck on your online journey. 🚀
#WordPressShortcode #WordPressShortcodeTutorial #HostingerAcademy
コメント