How to start using own shortcodes in WordPress

Many plugins offer the ability to use their functionalities via shortcodes.

You can use shortcodes defined by plugins (and rely on them, which I’ve found many times too risky, especially when updating the plugin).

The alternative is to start using your own shortcodes, and have full control over their behavior.

Before adding a first shortcode, you’ll need to make your blog ready, but it should take no more than 15 minutes.

Setting up own shortcodes

1. Create a separate file for shortcodes

Shortcodes are nothing more than WordPress functions. You can add them to functions.php file, but it’s much better to collect them in a separate document.

To do that, go to your WordPress theme’s folder and create a document named shortcodes.php. You can do that this way:

  • duplicate any of the existing php files, and rename it to shortcodes.php,
  • open shortcodes.php, remove all the text and save the clean file – it’s where we will add and store all the shortcodes.

2. Register shortcodes

To let WordPress know there are functions stored in a separate file, open functions.php and simly add this piece of code (remembering this rule):


Done. Now your WordPress blog is ready to execute your own shortcodes.

• • •

When you edit your WordPress files, it’s highly recommended to:

More on WordPress shortcodes:

[pi-archive number=5 tag=”shortcodes” ]

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: