Home Forums Add-ons Flexible Content Field Deactivate/Disable a Layout


Deactivate/Disable a Layout

  • Hi,

    i have set up different layout in one Flexible content field. Now i want to disable/deactivate one of this Layouts (not deleting).

    Is this possible ?

  • there isn’t any real way to disable a layout, but I did do something recently that might help you. What I needed was to exclude specific layouts if the client was not editing a specific post type.

    In a really simplified example this is what I did

    add_filter('acf/load_field/key=field_5808cd92035a5', 'remove_layout', 99);
    function remove_layout($field) {
      global $post;
      if (!is_admin() || !is_object($post) || (!isset($post->post_type) || !isset($post->ID))) {
        return $field;
      $post_type = $post->post_type;
      if ($post_type == 'acf-field-group' || $post_type == 'acf-field') {
        return $field;
      $layouts = $field['layouts'];
      $field['layouts'] = array();
      foreach ($layouts as $layout) {
        if ($layout['name'] != 'layout_name_to_remove') {
          $field['layouts'][] = $layout;
      return $field;
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Deactivate/Disable a Layout’ is closed to new replies.