Support

Account

Home Forums Backend Issues (wp-admin) how can I disable the parent category to be selected

Solved

how can I disable the parent category to be selected

  • Hello, how can I disable the parent category to be selected, and allow only select the category child with advanced, field selection!
    Can someone help me?

    I thank you.

  • Hi @saulo

    You should be able to remove it by using Javascript like this:

    add_action('acf/input/admin_footer', 'my_acf_disable_taxonomy_parent');
    
    function my_acf_disable_taxonomy_parent() {
        
        ?>
        <script type="text/javascript">
        (function($) {
            
            $(document).ready(function(){
                $(".acf-field-1234567890abc ul.acf-checkbox-list > li > label > input").remove();
            });
            
        })(jQuery);    
        </script>
        <?php    
        
    }

    Where ‘field-1234567890abc’ is the field key.

    I hope this helps. 🙂

  • Thank you very much, James.

  • Hi, James.

    One more thing on the input type checkbox and radio button works more in the selection option does not work will be you could help me?

    Thank you very much, James.

  • Hi @saulo

    I’m afraid you won’t be able to disable the choices in the selection because the choices are retrieved by using AJAX.

    You should be able to modify the query, though. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acffieldstaxonomyquery/.

    Hope this helps 🙂

  • Hi, James once again thank you for your help.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.