14+ years building on WordPress / Replies in under 5 hours
WordPress 1 min read · Updated July 2026

How to use Shortcodes in WordPress

AK
Ajay Khandal
WordPress Developer
TL;DR

WordPress shortcodes can be used two ways: typed directly into the editor or a page builder in square brackets like [your_shortcode_here], or called from inside a theme template or PHP file using the built-in do_shortcode() function. Knowing both methods lets you reuse the same piece of functionality whether you're writing content or building a template.

There are two ways to use a shortcode in WordPress:

1. In the Editor

If you’re calling a shortcode in the classic editor, the block editor, or any page builder, just write the shortcode in square brackets directly in the content.

Example:

[your_shortcode_here]
Example of a shortcode placed inside the WordPress content editor

2. In a Template or PHP File

If you want to run a shortcode inside a theme template or any other PHP file, use the WordPress built-in do_shortcode() function.

Example:

<?php echo do_shortcode( '[your_shortcode_here]' ); ?>
Example of do_shortcode() being used inside a PHP template file

For more on WordPress, check out this WordPress guide.

To dive deeper, see how to get the title in a WordPress template page.

AK

Written by Ajay Khandal

WordPress Developer — building, fixing and speeding up WordPress sites.

Work with me →