Support

Account

Home Forums Feedback Description field on Admin page

Helping

Description field on Admin page

  • On the admin page for where our field groups are listed, each field group’s description is merged into the same table column as the respective title.

    I can see in the plugin’s code that this is intentional. For my own reasons, I’d like to actually keep those separate. It would be great if there were an external method for skipping the part of code that merges the two columns.

  • Hi,

    Because the fact it’s done by javascript, there isn’t really a way to easily do that in the javascript side. However, knowing how the javascript works, there’s actually easy way to trick it.

    The javascript is basically looking for the column ‘acf-fg-description’ and append the value after the title. So, if we can make the javascript unable to find “acf-fg-description’, then we can keep the description and title separated.

    Here’s some code you can try:

    
    <?php
    
    // acf's hook order is 10, so let make ours 15 to run after 
    add_filter('manage_edit-acf-field-group_columns', 'rename_field_group_column', 15, 1);
    add_action('manage_acf-field-group_posts_custom_column', 'renamed_field_group_column_value', 15, 2);
    
    // basically we just don't want the column 'acf-fg-description', so we rename it.
    function rename_field_group_column($columns) {
        $flipped = array_flip($columns);
        $flipped[__('Description', 'acf')] = 'acf-fg-description-custom';
    
        return array_flip($flipped);
    }
    
    // we check the renamed column here and print the description
    function renamed_field_group_column_value($column, $post_id) {
        $field_group = acf_get_field_group( $post_id );
    
        if ($column == 'acf-fg-description-custom' && $field_group['description']) {
            echo '<span class="acf-description">' . acf_esc_html($field_group['description']) . '</span>';
        }
    }
    

    Cheers. 😇

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

The topic ‘Description field on Admin page’ is closed to new replies.