{"id":99660,"date":"2023-09-23T12:10:52","date_gmt":"2023-09-23T12:10:52","guid":{"rendered":"https:\/\/www.vwthemes.com\/?p=99660"},"modified":"2023-09-23T12:13:15","modified_gmt":"2023-09-23T12:13:15","slug":"shortcodes-in-wordpress","status":"publish","type":"post","link":"https:\/\/preview.vwthemesdemo.com\/old_website\/shortcodes-in-wordpress\/","title":{"rendered":"How To Use Shortcodes In WordPress For Integrating Plugins Into Your Website"},"content":{"rendered":"\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-introduction\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p class=\"has-black-color has-text-color\">Do you want to know how to use shortcodes in WordPress? Well, you must know this, as shortcodes have a lot of hidden benefits. And this blog will help you know everything about it.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">WordPress shortcodes are handy codes that simplify adding functionality to the website. These are meant to be so easy that adding features is like a game for kids.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">The best part is that it helps you stay away from the heavy coding, keeping it simple and easy. That\u2019s what almost every site owner wishes to have. Want to know more about it?<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">This blog is a complete guide on how to use shortcodes in WordPress. Also, you will find some pros and cons to adding shortcodes. You must even know the need to <strong><a href=\"https:\/\/www.vwthemes.com\/add-shortcode-wordpress\/\">add shortcodes to WordPress<\/a><\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-what-are-wordpress-shortcodes\"><strong>What are WordPress shortcodes?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Many of them might know what shortcodes are, right? But for those unaware, shortcodes are small code snippets for applying extensive functionality.<\/li>\n\n\n\n<li>They tend to come in a simplified and precise form that everybody loves to use.<\/li>\n\n\n\n<li>There are two elements that shortcodes comprise:<\/li>\n\n\n\n<li>There is a shortcode tag and a callback function. The shortcode tag is the name of the shortcode that we are going to use instead of a heavy code.<\/li>\n\n\n\n<li>The callback function is the feature that calls back to the shortcode.<\/li>\n\n\n\n<li>These small entities can be added to any part of the website, such as widgets, posts, pages, plugins, themes, and more.<\/li>\n\n\n\n<li>For this guide, we are going to tell you how to use shortcodes in WordPress plugins.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-the-need-to-use-shortcodes-in-wordpress\"><strong>The need to use shortcodes in WordPress<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You are now aware of what shortcodes are, and now there is a need to know their importance.<\/li>\n\n\n\n<li>Since they are handy tools, site owners find them easy to use.<\/li>\n\n\n\n<li>They seem to have a simpler version than writing a long code for hours. While it works faster than ever before,<\/li>\n\n\n\n<li>The content on your website looks clear and easy to navigate.<\/li>\n\n\n\n<li>Also, it can be used for automating some features on your website.<\/li>\n\n\n\n<li>Now, you might wonder why to use shortcode when we have the powerful<strong><a href=\"https:\/\/www.vwthemes.com\/gutenberg-wordpress-editor\/\"> Gutenberg WordPress Editor<\/a><\/strong>. That\u2019s true to some extent, but some of them are still not finding it at their own pace. So, they still prefer to use WordPress shortcodes.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-how-do-i-use-shortcodes-in-wordpress\"><strong>How do I use shortcodes in WordPress?<\/strong><\/h2>\n\n\n\n<p class=\"has-black-color has-text-color\">To know how to use shortcodes in WordPress, you need to stick your eyes below:<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">So, firstly, you need to create a plugin folder under wp-content.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">Under this, inside the plugins folder, create another folder named \u201cshortcode\u201d. Assume this will be the name of your plugin.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">Next, you need to create a file under the newly created folder along with the main plugin file.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">Once created, you need to paste this header code into it:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><strong>&lt;?php<br>\/<br>Plugin Name: Shortcode<br>Plugin URI: https:\/\/example.com\/Shortcode<br>Description: description of the plugin.<br>Version: 1.0.0<br>Author: Your Name<br>Author URI: https:\/\/example.com<br>Text Domain: plugin-name<br>License: GPL-2.0+<br>License URI: http:\/\/www.gnu.org\/licenses\/gpl-2.0.txt<br>\/<\/strong><\/cite><\/blockquote>\n\n\n\n<p class=\"has-black-color has-text-color\">Now, you must save this and visit the plugins page, where you will be able to see the newly created plugin. This is just an empty plugin, and you can activate it easily.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">The actual process begins when you learn how to use shortcodes in WordPress. Using a shortcode simply requires the shortcode tag and the callback function.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">The shortcode tag is the name of the shortcode, and the callback function is the feature used in the name of the shortcode.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">For this blog, we will take an example that will generate a contact form as a result.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">We will use \u201cnew_contact_form\u201d as the tag and the callback function as \u201crender_new_contact_form\u201d.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">The shortcode will somehow look like this:<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">add_shortcode( &#8216;new_contact_form,&#8217;render_new_contact_form&#8217;);<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">Below is the shortcode callback function:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><strong>function render_njengah_contact_form(){?&gt;<br>&lt;form&gt;<br>First name:&lt;br&gt;<br>&lt;input type=&#8221;text&#8221; name=&#8221;firstname&#8221; value=&#8221;Joe&#8221;&gt;<br>&lt;br&gt;<br>Last name:&lt;br&gt;<br>&lt;input type=&#8221;text&#8221; name=&#8221;lastname&#8221; value=&#8221;Njenga&#8221;&gt;<br>&lt;br&gt;&lt;br&gt;<br>&lt;input type=&#8221;submit&#8221; value=&#8221;Send&#8221;&gt;<br>&lt;\/form&gt;<br>&lt;?php}<\/strong><br><\/cite><\/blockquote>\n\n\n\n<p class=\"has-black-color has-text-color\">This basic form can be easily added to any post or page using the shortcode \u201cnew_contact_form\u201d.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">And now, we need to complete the entire code in the main plugin file to see if it&#8217;s working.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><strong>add_shortcode(&#8216;new_contact_form&#8217;,&#8217;render_new_contact_form&#8217;);<br>function render_new_contact_form(){?&gt;<br>&lt;form&gt;<br>First name:&lt;br&gt;<br>&lt;input type=&#8221;text&#8221; name=&#8221;firstname&#8221; value=&#8221;Joe&#8221;&gt;<br>&lt;br&gt;<br>Last name:&lt;br&gt;<br>&lt;input type=&#8221;text&#8221; name=&#8221;lastname&#8221; value=&#8221;New&#8221;&gt;<br>&lt;br&gt;<br>&lt;input type=&#8221;submit&#8221; value=&#8221;Send&#8221;&gt;<br>&lt;\/form&gt;<br>&lt;?php<br>}<\/strong><br><\/cite><\/blockquote>\n\n\n\n<p class=\"has-black-color has-text-color\">Once you have successfully added the code, simply save the file and then activate the plugin.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">On a new page, simply add the shortcode \u201cnew_contact_form\u201d and see whether the form appears or not.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-pros-and-cons-of-using-shortcodes-in-wordpress\"><strong>Pros and cons of using shortcodes in WordPress<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-the-pros\"><strong>The Pros<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Using shortcodes saves so much time compared to writing heavy codes for hours.<\/li>\n\n\n\n<li>These are easy to customize according to the user\u2019s needs.<\/li>\n\n\n\n<li>These are super user-friendly and can be easily added to any part of the website without advanced codes.<\/li>\n\n\n\n<li>These are compatible with most themes and plugins, so users are allowed to choose their desired themes and plugins.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-the-cons\"><strong>The Cons<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Relying totally on the shortcodes may create an issue if your theme or plugin is not well-updated.<\/li>\n\n\n\n<li>Most of the shortcodes are compatible with the themes and plugins. But some of them might not have the same compatibility.<\/li>\n\n\n\n<li>The person using shortcodes must have enough knowledge of basic coding skills.<\/li>\n\n\n\n<li>It is highly advised to use shortcodes with proper precautions to avoid security breaches.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-black-color has-text-color\" id=\"h-conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"has-black-color has-text-color\">This was all about learning how to use shortcodes in WordPress, but let&#8217;s take it up a notch and enhance your website even further. By incorporating<strong> <a href=\"https:\/\/www.vwthemes.com\/premium-wordpress-plugin\/\">premium WordPress Pugin<\/a>,<\/strong> you can elevate your site&#8217;s aesthetics and functionality to a whole new level.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">These are handy tools that, when used, always have extensive functionality on your website.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">No matter whether you are a beginner or a developer, these handy structures can be used by anyone. The reason is that they are beginner-friendly and require no heavy codes to write.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">In this blog, we have thoroughly shown everything you need to know about WordPress shortcodes. Specifically, we have focused on how to use shortcodes in WordPress plugins. Also, we have given various reasons to add them, as well as pros and cons.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color\">I hope the article has given you enough information about how to use shortcodes in WordPress.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Do you want to know how to use shortcodes in WordPress? Well, you must know this, as shortcodes have a lot of hidden benefits. And this blog will help you know everything about it. WordPress shortcodes are handy codes that simplify adding functionality to the website. These are meant to be so easy that [&hellip;]<\/p>\n","protected":false},"author":1809,"featured_media":99716,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-99660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-about-wp-themes"],"_links":{"self":[{"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/posts\/99660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/users\/1809"}],"replies":[{"embeddable":true,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/comments?post=99660"}],"version-history":[{"count":21,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/posts\/99660\/revisions"}],"predecessor-version":[{"id":99796,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/posts\/99660\/revisions\/99796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/media\/99716"}],"wp:attachment":[{"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/media?parent=99660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/categories?post=99660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preview.vwthemesdemo.com\/old_website\/wp-json\/wp\/v2\/tags?post=99660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}