Support

Account

Home Forums Feedback Description field on Admin page

Helping

Description field on Admin page

    • gamma

    • November 20, 2017 at 7:27 am

    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.

    • gummi

    • November 24, 2017 at 5:44 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.