Support

Account

Home Forums ACF PRO Override back-end labels ? Reply To: Override back-end labels ?

  • Hi @beee

    You should be able to do it by using a little bit advanced Javascript. Here’s an example how to do it:

    add_action('acf/input/admin_footer', 'my_acf_change_repeater_label');
    
    function my_acf_change_repeater_label() {
        
        ?>
        <script type="text/javascript">
        (function($) {
            $(document).ready(function(){
                
                // Hook when a new row is added
                acf.add_action('append', function( $el ){
                    
                    // Set default day and get the current total rows
                    var currentDay = "Monday";
                    var currentRow = $el.closest(".acf-table").find(".acf-row").length - 1;
                    console.log(currentRow);
                    
                    // Convert current row to day name
                    switch(currentRow) {
                        case 2:
                            currentDay = "Tuesday";
                            break;
                        case 3:
                            currentDay = "Wednesday";
                            break;
                    }
                    
                    // Replace the label
                    $el.find(".acf-field-123456789abc label").text(currentDay);
                    
                });
                
            });
        })(jQuery);    
        </script>
        <?php    
        
    }

    Where ‘.acf-field-123456789abc’ is the class of the field you want to target.

    I hope this helps 🙂