Ever need to include the functionality of a shortcode in a WordPress template file?
Awhile back I needed to create a template that auto changed some of the shortcode parameters depending on the URL it was accessed from. (Think single gallery page – that depending on the GET variables of the page – would show a specific and that gallery specific options. Instead of creating multiple gallery pages with the gallery shortcode hardcoded in – I decided to make one gallery page and then change the contents by simply modifying the URL using some GET variables which worked out great.
Example:
URL: http://www.example.com/gallery/?gallery-id=23
do_shortcode( '[jappler-gallery id=" '. intval( $_GET['gallery-id'] ).']' );
That code right there will then show the gallery with the ID 23 specified in the URL (?gallery-id=23).
This is just a quick way to utilize shortcodes inside the templates themselves while allowing you to make pages a bit more dynamic!
*Make sure to sanitize your GET variables.
Documentation on do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode