Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Johann Heyne

    (@jonua)

    Thread Starter seedpxwee5

    (@seedpxwee5)

    CSS applies to all tables. What if I have the “table” in a “repeater” ACF, and each table requires a different styling?

    Plugin Author Johann Heyne

    (@jonua)

    You can set different style classes in the table element.

    CSS

    .style1.table {
        /* your first table styles */
    }
    .style2.table {
         /* your second table styles */
    }

    HTML

    <table class="style1 table">
    <!--table row and cell elements -->
    </table>
    
    <table class="style2 table">
    <!--table row and cell elements -->
    </table>

    And then you could use an “choice” field next to the table field in the repeater to let the user choose style1 or style2.

    PHP

    // loop through the repeater rows of data
    while ( have_rows( 'repeater_field_name' ) ) : the_row();
    
        // get the table style choice fields value
        $tablestyle = get_sub_field( 'tablestyle' );
    
        $table = get_sub_field( 'your_table_field_name' );
    
        if ( $table ) {
            echo '<table class="' . $tablestyle . ' table">';
               // other table elements
            echo '</table>';
        }
    
    endwhile;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Color Specific Columns’ is closed to new replies.