Create shortcode

1) Open  function.php

2) Create a function and do something with the function.

Example:

function manojSingh(){
echo 'Hi! My Name is Manoj Singh';
}
add_shortcode (' manoj','manojSingh '); 

3) Here ‘add_shortcode’ function (WP function) is used for create short code of your function, First parameter is used for short code and second is your function name.

Now add short code in editor like: [manoj]. If you want to add short code in a file like template then use do_shortcode WP function.

Example:

<?php
echo do_shortcode('[manoj]')';
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s