Skip to content

Instantly share code, notes, and snippets.

@azharisubroto
Forked from anonymous/functions.php
Created September 13, 2016 10:53
Show Gist options
  • Save azharisubroto/3ee25b38eeea0a30cc906954a90e6855 to your computer and use it in GitHub Desktop.
Save azharisubroto/3ee25b38eeea0a30cc906954a90e6855 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