Categories
Wordpress

How to Create WordPress Shortcodes

How to Create WordPress Shortcodes

In WordPress shortcode is one of the greatest feature that enable you to perform functions inside in a wordpress posts. WordPress shortcodes allow customizing of the layout and inserting certain formatting snippets in your post so quickly.

INTRODUCTION:-

The basic purpose of using a shortcode is to replace the placeholder with your very own custom snippet of HTML. This function allows you to customize layout of posts, insert different types media and snippets of HTML.

HOW TO CREATE YOUR OWN SHORTCODE FUNCTION:-

A basic wordpress shortcode consists of a simple function in which we insert inside of the “Functions.PHP” file.

This function can be inserted anywhere in your function.php file.

I am here creating a Code box to contains code in it.

function codebox() {return '
<div class="code">
<h3>Code Snippet</h3>
add_shortcode('hightech', 'codeboxbox');

Now to show this in your post simply add below code where you want to display this:-

[hightech]

For more check out here:- Here