Home Forums Add-ons Flexible Content Field Wrapping all layouts after a certain layout


Wrapping all layouts after a certain layout

  • I have a flexible content field with a bunch of different layout options. Among the layouts, I have one special “new_group” layout, which just outputs a horizontal line:

    if (get_row_layout() == 'new_group') {
        echo '<hr class="new_group">';
    if (get_row_layout() == 'another_layout') {
    if (get_row_layout() == 'yet_another_layout') {

    Then with some jQuery, I wrap all other layouts that follow the <hr class="new_group"> in a <div class="grouped_layouts">.

    $(".new_group").each(function() {
        $(this).nextUntil(".new_group").addBack().wrapAll("<div class='grouped_layouts'></div>");

    The idea is very similar to the way the ACF field group builder works with the Tab and Accordion fields – everything after a Tab or an Accordion will be wrapped until the next instance of a Tab or Accordion, however I’m using this technique on the front-end.

    My question is – can I do what I’m currently doing with jQuery, but instead by only using PHP? It would be even better if I don’t have to create the dummy <hr> element but just have the wrapping <div> which is all that’s needed.

Viewing 1 post (of 1 total)

The topic ‘Wrapping all layouts after a certain layout’ is closed to new replies.