Create shortcode in WordPress

Shortcodes are one of the best things about WordPress. It makes it extremely easy to use.

A shortcode is a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut. https://en.support.wordpress.com/shortcodes/

Let us create a simple form just to show you how easy it is.

  1. Open your functions.php
  2. Copy and paste the following code into your functions file.
  3. Place the shortcode on any WordPress page.
  4. You can also call a Shortcode with PHP.
    1. ¬† do_shortcode(‘[showform]’);
function create_form(){
?>
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname"><br>
Message: <textarea name="message"> Enter text here...</textarea>
</form>]
<?php
}
add_shortcode('showform', 'create_form');
matrix-2502935_640
Once a week we send a digest with the most popular articles.

We are more than just a Hosting company!

AdminWP Host, Maintain (Site-care), Secure and Backup WordPress websites.