Last active
November 13, 2019 09:17
-
-
Save mono96/eb00504daf2435b0eb16def2d8836967 to your computer and use it in GitHub Desktop.
tag_search_controlpanel_wordPress_mono96
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 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