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

AEO vs SEO vs GEO: a search bar above an AI answer panel that cites three web sources

AEO for B2B Companies: Get on ChatGPT Shortlists in 2026

A B2B buyer used to search, open ten tabs and build a shortlist over weeks. Many now ask ChatGPT, Copilot…

Shafeeq Khan
November 11, 2026
Hire an MLOps engineer illustration: a web platform with automated deployment pipelines on an isometric navy platform

Hire an MLOps Engineer: Skills, Salary and Cost in India 2026

Your data scientist built a model that works in a notebook. Three months later it is still not in production,…

Shafeeq Khan
November 10, 2026
AI visibility audit illustration: a rising search visibility chart, an eye symbol and ranked podium blocks

Track ChatGPT Traffic in GA4: AI Search Referrals in 2026

Your sales team says prospects mention ChatGPT on calls, but your analytics shows only a trickle of AI visits. Both…

Shafeeq Khan
November 9, 2026
,

Leave a Reply

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