Support

Account

Home Forums Backend Issues (wp-admin) ACF block – background colour

Unread

ACF block – background colour

  • Hi,

    I have a bunch of ACF blocks, and a have added a status field for each block (active or disabled). Basically I want to be able to show / hide block in front end, all good so far, I can do that on Front-End. Struggling with back-end where if a block status is set to disabled, it should have a different background to other blocks (in admin panel – when editing a page).

    I don’t know how I can target individual block with ‘disabled’ status. Below is the code I have so far. I would imagine I have to do a for/while loop and see which block has a status of disabled. But I don’t know how to go about it.

    Any help would be much appreciated.

    Thanks.

    function my_acf_admin_head() { 
    if(get_field('status') == 'disabled') {
    ?>
        <style type="text/css">.acf-accordion { background-color: red } </style>
        <?php 
    } }
    
    add_action('acf/input/admin_head', 'my_acf_admin_head');
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.