How to insert shortcode in WordPress?

This article was written by in April 6, 2014, & may not be posted on other sites!
Original source url for this article: How to insert shortcode in WordPress?

How to insert shortcode in WordPress?
When working with a custom theme in WordPress you might want to add the functionality of a plugin directly into a template or php file. Many plugins offers shortcodes to be used with different parameters. This is how to insert the shortcode in WordPress custom themes, templates and php-files:


The WordPress shortcode

The shortcode might look something like this:
[nggallery id=1]
and can be pasted directly into posts and pages through the WordPress admin.


How to insert shortcode in wordpress php-files

Simply pasting in [nggallery id=1] in a php-file will not work. To use shortcodes in WordPress php-files you need to use WordPress function do_shortcode();
Something like this:

<?php echo do_shortcode('[nggallery id=1]'); ?>


Spread the word


Leave a Reply

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