Home Forums ACF PRO Backend: Use Accordion in Tabs does not work Reply To: Backend: Use Accordion in Tabs does not work

  • I tested the accordions with the new ACF v5.6.7. If you want to use the accordions within tabs, you must use a last accordion field with “Endpoint” set to Yes before you start the next tab.

    It’s a bit more complicated than with the Accordion Tab Field plugin – but has the advantage that you can also create tabs within an accordion.

    The only downer: If you have a site already using the Accordion Tab Field plugin both accordions not working. That’s because the core accordion and the plugins accordion using the same field name in code. That’s why ACF’s script and CSS for the accordion also affects the fields created by the plugin and vice versa.

    Since I use the plugin on many pages of my clients, I’ve been looking for a solution to continue to use the plugin (so I do not have to change all affected fields) and still be able to update to the new ACF version.

    Here is my approach (for ACF Pro only):

    First be save that you didn’t have set up accordion fields with the new ACF core accordion field. Otherwise, these will also be changed.

    I changed the field name in the Accordion Tab Field plugin acf-accordions-v5.php and all necessary class names in the .js and .css files to an unique name (e.g. my_accordion). The affected class names are:
    .acf-field-accordion -> .acf-field-my-accordion
    .acf-field-object-accordion -> .acf-field-object-my-accordion)

    After that the old accordion fields are broken and now you should not update the field groups.

    Now you have to go into your database and open the wp_post table (change the suffix “wp”, if you have defined your own suffix in the wp-config.php).


    In this table all the accordion fields are saved. To list them all query like this:
    SELECT * FROM wp_posts WHERE post_content LIKE '%"type";s:9:"accordion"%'

    To change this entries use a query like this:

    UPDATE wp_posts
    SET post_content = REPLACE(post_content, '"type";s:9:"accordion"', '"type";s:12:"my_accordion"')
    WHERE post_content LIKE '%"type";s:9:"accordion"%'

    The replacement string must contain the field name you set in the acf-accordions-v5.php and you have to set the s parameter to the length of that string. In the example query the field name my_accordion is used and therefore it must be s:12.

    Now your fields are re-linked to the Accordion Tab Field plugin fields.

    I hope this approach works for anyone who wants to use the new ACF v5.6.7 and the plugin together.