Rechercher un médium
// Add Shortcode
function search_medium() {
// Code
function wn_custom_tax_dropdown( $taxonomy, $id, $option, $exclude ='' ) {
$terms = get_terms( $taxonomy, array('exclude' => $exclude ) );
if ( $terms ) {
printf( '<select name="%s" class="postform" id="%s">', esc_attr( $taxonomy ), esc_attr( $id ) );
printf( '<option value"">%s</option>', esc_attr( $option ) );
foreach ( $terms as $term ) {
if ( $term->count < 1) continue;
printf( '<option value="%s">%s (%s)</option>', esc_attr( $term->slug ), esc_html( $term->name ) );
}
print( '</select>' );
}
} // wn_custom_tax_dropdown()
add_action('template_redirect','wn_search_medium' );
function wn_search_medium() {
function wn_nav_search_medium() { ?>
<nav class="nav-search" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
<div class="wrap center">
<br>
<h4>Sélectionnez votre médium : </h4>
<ul class="menu">
<li class="menu-item">
<?php wn_custom_tax_dropdown( 'mediums', 'mediums', 'Sélectionnez un médium', '' ); ?>
<script type="text/javascript">
var menuMedium = document.getElementById("mediums");
function onCatChange() {
if ( menuMedium.options[menuMedium.selectedIndex].value != -1 ) {
location.href = "<?php echo home_url();?>/mediums/"+menuMedium.options[menuMedium.selectedIndex].value+"/";
}
}
menuMedium.onchange = onCatChange;
</script>
</li>
</ul>
<br>
</div>
</nav>
<?php } // function wn_nav_search_medium()
} // function gn_affichage_contenu_archive()
}
add_shortcode( 'wn_search_medium', 'search_medium' );