Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Taxonomy Dropdown Template
<div class="tools-dropdown">
<form id="tool-category-select" class="tool-category-select" method="get">
// Create and display the dropdown menu.
'orderby' => 'NAME', // Order the items in the dropdown menu by their name.
'taxonomy' => 'tools', // Only include posts with the taxonomy of 'tools'.
'name' => 'tools', // Change this to the
'show_option_all' => 'All Tools', // Text the dropdown will display when none of the options have been selected.
'selected' => km_get_selected_taxonomy_dropdown_term(), // Set which option in the dropdown menu is the currently selected one.
) );
<input type="submit" value="View" />
<section id="tools-listing">
<?php $tools_in_taxonomy_term = km_get_tools_in_taxonomy_term(); ?>
<!-- If posts were found, -->
<?php if ( $tools_in_taxonomy_term->have_posts() ) : ?>
<!-- Loop through every post. -->
<?php while ( $tools_in_taxonomy_term->have_posts() ) : $tools_in_taxonomy_term->the_post(); ?>
<!-- Display each post's title and content - you can change this section to display whatever post content you want. -->
<article class="tool-entry">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment