Skip to content

Instantly share code, notes, and snippets.

@mikesusz
Created July 11, 2013 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesusz/5977998 to your computer and use it in GitHub Desktop.
Save mikesusz/5977998 to your computer and use it in GitHub Desktop.
quick & dirty hack to put a Tags dropdown on the "All Posts" page in WordPress admin.
add_action('restrict_manage_posts','my_restrict_manage_posts');
function my_restrict_manage_posts()
{
global $typenow, $wp_query;
if ($typenow=='post')
{
$current_tag = $wp_query->query_vars['tag'];
$tags = get_terms('post_tag');
?>
<select name="tag">
<option value="">All Tags</option>
<?php
foreach( $tags as $tag )
{
echo '<option value="' . $tag->slug . '"';
if( $tag->slug == $current_tag )
{
echo ' selected="selected" ';
}
echo '>' . $tag->name . '</option>';
}
?>
</select>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment