Skip to content

Instantly share code, notes, and snippets.

@nicolechung
Created March 14, 2012 00:23
Show Gist options
  • Save nicolechung/2032931 to your computer and use it in GitHub Desktop.
Save nicolechung/2032931 to your computer and use it in GitHub Desktop.
Wordpress: sort admin columns for a custom post
add_action('restrict_manage_posts','restrict_menu_post');
function restrict_menu_post() {
global $typenow;
global $wp_query;
if ($typenow=='menu') {
$taxonomy = 'menutype';
$menu_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$menu_taxonomy->label}"),
'taxonomy' => $taxonomy,
'name' => 'Menu',
'orderby' => 'name',
'selected' => $wp_query->query['term'],
'hierarchical' => false,
'depth' => 3,
'show_count' => true, // Show # listings in parens
'hide_empty' => false, // Don't show menu types w/o listings
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment