Created
July 27, 2018 10:33
-
-
Save elvismdev/3ddd82a701ed13b59f08aac8e610fad8 to your computer and use it in GitHub Desktop.
WordPress: Remove parent dropdown selector from hierarchical taxonomy.
This file contains hidden or 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
| <?php | |
| function remove_tax_parent_dropdown() { | |
| $screen = get_current_screen(); | |
| if ( 'region' == $screen->taxonomy ) { | |
| if ( 'edit-tags' == $screen->base ) { | |
| $parent = "$('label[for=parent]').parent()"; | |
| } elseif ( 'term' == $screen->base ) { | |
| $parent = "$('label[for=parent]').parent().parent()"; | |
| } | |
| } elseif ( 'country' == $screen->post_type ) { | |
| $parent = "$('#newregion_parent')"; | |
| } else { | |
| return; | |
| } | |
| ?> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { | |
| <?php echo $parent; ?>.remove(); | |
| }); | |
| </script> | |
| <?php | |
| } | |
| add_action( 'admin_head-edit-tags.php', 'remove_tax_parent_dropdown' ); | |
| add_action( 'admin_head-term.php', 'remove_tax_parent_dropdown' ); | |
| add_action( 'admin_head-post.php', 'remove_tax_parent_dropdown' ); | |
| add_action( 'admin_head-post-new.php', 'remove_tax_parent_dropdown' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment