Created
November 20, 2013 20:28
-
-
Save obstschale/7570444 to your computer and use it in GitHub Desktop.
WordPress: add additional filter options to post type site for each taxonomy which is used for this plugin
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
function filter_posts() { | |
global $typenow; | |
if( 'podcast' == $typenow ){ | |
/* push each taxonomy name, which is used in this plugin | |
* into _tax array. filter_posts() uses this array | |
* to know which taxonomy is used and display filter options | |
* for that | |
*/ | |
foreach ( $_tax as $tax_slug ) { | |
$tax_obj = get_taxonomy( $tax_slug ); | |
$tax_name = $tax_obj->labels->name; | |
$terms = get_terms($tax_slug); | |
echo "<select name='$tax_slug' id='$tax_slug' class='postform'>"; | |
echo "<option value=''>Show All $tax_name</option>"; | |
foreach ( $terms as $term ) { | |
$selected = ''; | |
if ( isset( $_GET[$tax_slug] ) ) { | |
if ( $_GET[$tax_slug] == $term->slug ) | |
$selected = ' selected="selected"'; | |
} | |
echo '<option value='. $term->slug, $selected,'>' . $term->name .' (' . $term->count .')</option>'; | |
} | |
echo "</select>"; | |
} | |
} | |
} | |
// add additional filter options to podcast site | |
add_action( 'restrict_manage_posts', 'filter_posts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment