What is shortcode in? and how to create shortcode in wordpress?


A shortcode is a WordPress-specific code that lets you do many things with very small effort.
Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut.


<?php add_shortcode( 'shortcode-name' , 'shortcode-function-name'); ?>

function FuncTest( $attr ) {
    $test= 'Hello World';
    return $test;    
 add_shortcode( 'ecodeblog-test', 'FuncTest' );

Above i have add function for shortcode, Now I’ll explain you how can you use this in your wordpress project.

How to use shortcode in PHP

<?php echo do_shortcode( ‘[your shortcode]’ ); ?>

You can use your shortcode like this

<?php echo do_shortcode('[ecodeblog-test]'); ?>

Thank you, Let me know if you have any query 🙂

Leave a Reply