I’m trying to get the table to work in a flexible content layout using the page builder shortcode. If I use the default shortcode you have provided for Elementor (I’m using Beaver Builder although), I can get the table to work outside of a flexible content field and on it’s own. I found this on the forums – https://wordpress.org/support/topic/table-is-not-showing-up-with-elementor/ that had the table in a group field so I copied that the function code thinking it might work but it hasn’t. The table isn’t saving any data when I publish the page, which is because of the function being wrong right?
1.) Reading the field data for the Flexible Content field type differs from the Group field type. Therefore, the code for the shortcode must be adapted to your requirements.
2.) Table field data should always be saved when a page is published or saved, regardless of the shortcode function. Do you get an empty table in the table editing view after saving a page like in the following screenshot?
Thanks for the update. I found I had two flexible layouts of table and when I deleted one the table data saved.
I’ve since updated the function code and shortcode with your updated code and the data is now displaying. But the problem I now have is the data is not displaying with all the other layouts. It is also duplicating the tables. I have created two quick table layouts and now four are displaying. See the image below of the console.
This is how the layouts display in Beaver Builder.
In your Elementor example, the shortcode call is already in a flexible content loop and in a layout context due to the surrounding wpbb shortcodes. I hadn’t taken this situation into account, but have now adjusted the shortcode code example. Now you can directly use subfields of a Flexible Content Layout via the table shortcode. In your flexible content example the shortcode would now look like this:
[tablefield subfield-name="table"]
Note that in this context the shortcode parameter field-name is now subfield-name!
Thanks for the update. The table is now appearing in the correct place IF I don’t change the html shortcode. If I update the shortcode to the [tablefield subfield-name=”table”] the tables don’t display, see below. The fields are empty and the space is blank on the page.
If I don’t change the shortcode to the new one, the tables display but are still duplicating. I’ve created four layouts on one page and in each layout it is displaying the other layouts, see below.
I bought the Beaver Builder Plugin and investigated the problem. It seems that only Beaver shortcodes are executed in the context of the flexible content layout shortcode [wpbb-acf-layout]. The shortcode of the table field is then called later outside of that ACF loop in the wrong context and cannot function.
One solution to the problem would be to use the WordPress filter do_shortcode_tag , that filters the output created by a shortcode callback. Here is the filter that looks for tablefield shortcodes and then executes shortcodes. You can paste it in your functions.php. Then may the tables will appear.