Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2016 10:51
Show Gist options
  • Save anonymous/c1eb945c40060dd861506c28fbf2e482 to your computer and use it in GitHub Desktop.
Save anonymous/c1eb945c40060dd861506c28fbf2e482 to your computer and use it in GitHub Desktop.
Query Args
<?php
function themeslug_query_vars( $qvars ) {
$vars[] = 'headertype';
return $vars;
}
add_filter( 'query_vars', 'themeslug_query_vars' , 10, 1 );
<?php
$headernumb = get_query_var( 'headertype' );
// Kalo query_var ada, jadi prioritas
if( $headernumb ){
$headertype = $headernumb;
// Kalo query_var di browser url address gak ada, tarik dari theme option
} else {
$headertype = my_option('headertype', 3);
}
// tarik file: header-n.php
get_template_part('header', '$headertype');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment