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

Isometric illustration of an AI voice agent: a smartphone with a sound wave linked to a headset robot receptionist, a booking calendar and stacks of coins

AI Voice Agent Cost in 2026: Platforms vs a Custom Build

A missed call at a clinic, salon or service business is often a missed booking. That is why owners now…

Shafeeq Khan
October 22, 2026
Isometric illustration of an AI answer panel citing a business website, with an AI crawler and search pages connected to it, for an AEO services guide

AEO Services: Get Cited in ChatGPT and Google AI Overviews

When a buyer asks ChatGPT, Perplexity, Gemini or Google’s AI Overviews “who builds X in India?” or “what does Y…

Shafeeq Khan
October 19, 2026
Isometric illustration of an old AI model chip being swapped for a new one in a server that powers web and mobile apps, for a GPT-4o API migration guide

GPT-4o API Shutdown: Migrate Your App Before 14 January 2027

If your chatbot, document pipeline or internal tool still calls GPT-4o or GPT-4.1, it has a deadline. On 14 October…

Shafeeq Khan
October 19, 2026
,

Leave a Reply

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