WordPress.org

Ready to get started?Download WordPress

Forums

Dashboard > Category filter does not work after new category (1 post)

  1. wzshop
    Member
    Posted 1 year ago #

    Hello everyone,
    I created this filter to exclude the possibility for admins to create a parent category:

    function no_parent_category() {
    	 global $pagenow, $post;
        if(($pagenow == 'post.php' || $pagenow == 'post-new.php') && $post->post_type=='blog')
        {
    ?>
     <script type="text/javascript">
    		   jQuery(document).ready(function($)
                {
                 $('#newcategory_parent option[value=-1]').remove();
                });
            </script>
    
    <?php
    }
    }
    add_action('admin_head', 'no_parent_category');

    This works great, but if an admin create a new subcategory (i.e. on the post-new.php page) in the category "floatbox", the option to create a parent category shows up again.

    Does anybody know why this is the case and how to prevent it from showing up?
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic