How to Create a Shortcode in WordPress

preview_player
Показать описание
💥 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.
____________________________________________

📚 Get our eBooks!

___________________________________________

📌 Handy links

____________________________________________

⭐ Follow Us ⭐

____________________________________________

🕒 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

2️⃣ Create the Shortcode Function

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

5️⃣ Test the Parameters

👉 Let’s test the parameters by adding the shortcodes to your WordPress post.

6️⃣ Create an Enclosing WordPress Shortcode

7️⃣ Add the Enclosing Shortcode to the Website

👉 For the Facebook anchor text:

👉 For the Twitter anchor text:

________________________________________

▶ Want to see more awesome tutorials like this one in the future? Consider subscribing 😁

▶ If you have questions, don’t hesitate and join our Facebook group for more help:
____________________________________________

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
Рекомендации по теме
Комментарии
Автор

💥Use the discount code WP10 to get 10% OFF!

HostingerAcademy
Автор

My site is hosted on hostinger, stuck at one point. I have multiple shortcodes but want to show in a single page but based on drop-down selection. Currently created a bunch of pages, i.e. a page for a shortcode. Please suggest.

yourniftysolutions
Автор

I want to create a short code for City and State. How to do that?

royalcrown
Автор

Ok here is the other side: I've inherited a website to admin and it is strewn with short-codes. How do I find the object represented by the short-code. In the editor all I see is the short-code.

kentek
Автор

Hello that such a great video I congratulate you, an apology if there is any mistake in writing, but I am from Mexico, and my English is not very good, I am supporting the translator, and well I would like to see if you were so kind to be able to guide me with the following, I have an online academy with wordpress woocommerce and LernDash, and well my problem is that the payment gateway I do with WooCommerce and then I link the courses with the products, and in the store the products come out, but I really do not like the format it has, I have seen some templates that look great because the photo of the author of the course comes out, the name, etc, but I can't do it in the woocommerce product That's why I thought about touching the PHP code, to see if I could add those data I need, the name of the author, the image if it is enrolled etc, these I guess are shorcodes of lerndash, and well in conclusion not to get dizzy (Jejejeje), It would be how I can add those shorcodes in the WooCommerce product to create a more attractive product sheet, p.s. I can not put the templates that I liked, because they are not compatible with lerndash, thank you very much for the attention you can give to this message, in advance

profeduardo
Автор

my functions.php file is a bit different .. it just contains <?php but no ?>
it oddly ends with an empty line, just below somthing like this :
// endregion

new OCEANWP_Theme_Class();

.. but no ?> so i don't where to put the include line

issamehtp