Created
April 22, 2015 23:05
-
-
Save ryansnowden/a8caacfb0ed80f6a7b12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Load landing page template & register shortcodes from URL query | |
* | |
* @return void | |
*/ | |
add_action('template_redirect', 'landing_template'); | |
function landing_template() { | |
if (get_post_type() == 'landing') { | |
$template = get_field('template'); | |
if (isset($template)) { | |
$parts = wp_parse_args($_SERVER['QUERY_STRING']); | |
foreach ($parts as $key => $value) { | |
add_shortcode($key, 'return_shortcode'); | |
} | |
load_template(TEMPLATEPATH . "/single-landing-$template.php"); | |
exit; | |
} | |
} | |
} | |
/** | |
* Return the value from the URL in place of a shortcode | |
* | |
* @return string Querystring | |
*/ | |
function return_shortcode($atts, $content, $name) { | |
if (isset($name)) { | |
return $_GET[$name]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment