WordPress Shortcode.

Code

Since Version 2.5 WordPress supports so called ‘Shortcodes’.
Example:

Shortcodes can also be used with attributes as the following example shows:
Example:

WordPress have some of the shortcodes by default (for example the audio one).
The following shortcodes are included with WordPress:

hortcodes are of both type singular and paired.

We can define custom shortcodes using add_shortcode
Example:

Calling Shortcode

In Php:

do_shortcode('[MyFirstShortcode]');

In Editor:

[MyFirstShortcode];

Defining Shortcode


add_shortcode('MyFirstShortcode','MyFirstShortcodeCallback');
function MyFirstShortcodeCallback() {
    echo 'hello';
}

Shortcodes with attributes as the following example shows:
Example:

Calling Shortcode

In Php:

do_shortcode('[MyFirstShortcode title="This Is Shortcode"]');

In Editor:

[MyFirstShortcode  title="This Is Shortcode" ];

Defining Shortcode

add_shortcode('MyFirstShortcode','MyFirstShortcodeCallback');
function MyFirstShortcodeCallback($attr) {
    echo $atts['title'];
}
//output This Is Shortcode

Related reading:

Shiv Kumawat

Executive Director & CEO

Shiv Kumawat is the CEO of Eoxys IT Solution LLP, the Jaipur-based IT company he has led since 2009. An AI & IT Solutions Consultant with 16+ years of experience, he works with startups and enterprises to turn ideas into market-ready SaaS platforms, mobile apps and AI-driven solutions. His team has delivered 700+ projects across SaaS, mobile and web apps, automation and AI. He previously served as Chief Technology Officer for a US company.

Latest Posts

Food delivery app development cost in the UK: delivery rider with an insulated bag and a takeaway order at a townhouse door

Food Delivery App Development Cost in the UK (2026)

A food delivery order in the UK succeeds or fails in about forty minutes: the kitchen has to accept it…

Shafeeq Khan
December 1, 2026
Colour photograph illustrating the Eoxys blog post 'Year-End AEO Checklist: Get Ready for AI Search in 2027', used as the featured image for year end aeo checklist.

Year-End AEO Checklist: Get Ready for AI Search in 2027

December is a good time to check whether your website is ready for how people search in 2027. AI answers…

Shafeeq Khan
December 1, 2026
Logistics app development cost in Canada: smiling delivery driver in a red uniform at the wheel of a white van

Logistics App Development Cost in Canada (2026)

A courier app in Canada earns its keep in the moments nobody demos: the driver who loses signal in a…

Shafeeq Khan
November 30, 2026
,

Leave a Reply

Your email address will not be published. Required fields are marked *