How to use wordpress shortcodes in php code

A great option in wordpress are shortcodes.

Shortcodes can easily be created – and nearly every plugin provides handy shortcodes.

These can contain widget content or even single values to work with.

Placing a wordpress shortcode

If you want to place a shortcode in a post or page just paste it – that’s what shortcodes are for. 🙂

[su-button]Some Button[/su-button]

Placing wordpress shortcodes in a php file

It’s quite easy to implement it in php, just drop this line and paste your shortcode between the ' '.

<?php echo do_shortcode('[]'); ?>

Shortcode Example

<?php echo do_shortcode('[su-button]Some Button[/su-button]'); ?>

This shortcode is generated with the plugin Shortcodes Ultimate.

This will be generated:
Some Button

– Kev