Skip to content

Instantly share code, notes, and snippets.

@mono96
Last active November 13, 2019 09:17
Show Gist options
  • Save mono96/eb00504daf2435b0eb16def2d8836967 to your computer and use it in GitHub Desktop.
Save mono96/eb00504daf2435b0eb16def2d8836967 to your computer and use it in GitHub Desktop.
tag_search_controlpanel_wordPress_mono96
//投稿一覧リストの上にタグフィルターを追加
function custmuize_restrict_manage_posts_exsample(){
global $post_type, $tag;
if ( is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
$dropdown_options = array(
'show_option_all' => get_taxonomy( 'post_tag' )->labels->all_items,
'hide_empty' => 0,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $tag,
'name' => 'tag',
'taxonomy' => 'post_tag',
'value_field' => 'slug'
);
wp_dropdown_categories( $dropdown_options );
echo '<input type="hidden" name="post_type" value="post">';
}
}
add_action('restrict_manage_posts', 'custmuize_restrict_manage_posts_exsample');
//投稿一覧で「全てのタグ」選択時は$_GET['tag']をセットしない
function custmuize_load_edit_php_exsample(){
if (isset($_GET['tag']) && '0' === $_GET['tag']) {
unset ($_GET['tag']);
}
}
add_action('load-edit.php', 'custmuize_load_edit_php_exsample');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment