Home Forums Add-ons Flexible Content Field Is it possible to load all layouts on default? Reply To: Is it possible to load all layouts on default?

  • Hey Elliot,

    I work with a developer (I’m a designer myself), he’s pretty skilled in WordPress filters and all that. Still we are having problems to apply the filter to the flexible content fields.

    We did get default values in non-flexible content fields, using this code:

    function my_acf_load_value( $value, $post_id, $field )
        // run the_content filter on all textarea values
        $value = "1"; 
        return $value;
    add_filter('acf/load_value', 'my_acf_load_value', 10, 3);

    The problem here is that the flexible content field isn’t mentioned anywhere. When we tried this, we had no luck

    add_filter('acf/load_value/type=flexible_content', 'my_acf_load_value', 10, 3);

    – I’m just gonna think out loud from here –
    My point is, we can get the filter to work, but how can we apply it to the flexible content so that they are expanded by default?

    (how) Do we apply the filter to the subfields?

    Our fields are set like this:
    – Flexible content field
    — Subfield
    — Checkbox ‘r1’
    — Checkbox ‘r2’
    — Subfield
    — Textfield ‘r1’
    — Textfield ‘r2’
    — Subfield
    etc. etc.

    I imagine it wouldn’t be wise to apply the filter to a fieldname such as ‘r1’ because they could be checkboxes or textfields. Thus I think we have to apply the filter to the field_type, mostly being textfields and checkboxes.

    Meaning I could use this:
    add_filter('acf/load_value/type=checkbox', 'my_acf_load_value', 10, 3);
    To add default values to checkboxes. But we need to know how to apply this filter not to checkboxes, but to checkboxes in flexible content fields (or all checkboxes for all I care) – as long as the fields are shown by default.

    Furthermore I wanted to thank you for a fantastic product. We use it allot and overall it’s going really smooth. I realize we’re asking some pretty specific stuff here. I just hope we can figure this out (for our client’s sake).