Skip to content Skip to sidebar Skip to footer

Easy ways to create shortcodes in WordPress

WordPress

WordPress Self Hosting has more features than the WordPress builder and one of the things that really help administrators is the shortcode API function that is provided directly from the WordPress package. The benefit of this feature, of course, is to install a script like a quick code and not have to edit the code again or multiple times as you can view / run large scripts with very small code. Many plugins currently share this feature to make it easier for administrators to view it in the section they want.

For example, if someone wants to display PHP code in a post, is that not right, of course? but with the help of this shortcode it can be easy and not satisfy the article. Examples in plugins Contact form, usually the plugin shares ready-to-use shortcodes, it can be posts, pages or other parts that text editors support, and the calling process is not much either, since it consists of only a few characters. Here I am going to share an easy way to create the simplest WordPress self hosting shortcode.

If you still don’t know what a shortcode is, I’ll explain a little more to you. Shortcodes are the fastest way to show something in just a small piece of text / code and here I am giving an example of the suffix I usually use in every article, namely Hopefully useful and good luck and to display it, I no longer write down all of those words and just use this code [akhir]. So with a little code, it can show something big. OK this is the method I am using. Before doing this, take a look at the code below and how to use it.

function akhir_shortcode() {return 'Semoga bermanfaat dan Selamat mencoba';}add_shortcode('akhir', 'akhir_shortcode');
  1. First, log into the WordPress dashboard page and highlight the menu Appearance then click on the submenu editor.

  2. Then look at the right side of the template text, please click on Features.php.

  3. Now please copy the code above and paste it below after the code and if so please scroll down and click File updates.

The conclusion from the code above is just a function called end_shortcode and I just added a direct return function as a viewer, and underneath there is again a special WordPress function, the purpose of which is to convert the function into a shortcode, so you can see that above Function end_shortcode I changed it until the end so the summoning will be like that [akhir]. You can develop the code above into something bigger than just text, the above is just a small example, the shortcode API provided has a lot of extra functionality and you can see them right on the page. This page. If you have anything to ask, please comment.

Hopefully useful and good luck