Execute WordPress Shortcode from PHP

Sometimes when building themes, we need to execute shortcode directly from php.  This can be for things such as Forms, Sliders, Galleries etc.

Below is the code needed. Replace the code between the ‘ and ‘ marks with your own. (Few examples below).

Execute Category List
<?php echo do_shortcode('[catlist id=1 numberposts=5)]'); ?>

Execute Slidedeck Slider
<?php echo do_shortcode('[SlideDeck2 id=7]'); ?>

Execute Gravity Form
<?php echo do_shortcode('[gravityform id="1" name="Contact Me" ajax="true"]'); ?>

Execute NextGEN Gallery
<?php echo do_shortcode('[nggallery id=12]'); ?>