-1

I want to create a shortcode using ACF Repeater Field and so I've found this code and when I tried to apply it on my website it doesn't work. Am using genesis frame work.

my aim is create a shortcode using ACF Repeater Field and display table in post or page.

Here is my code in functions.php:

function menu_loop () { 

    $menu =   '<div class="entry-content dishes">';
// check if the repeater field has rows of data
        if( have_rows('menu_sections') ):

            // loop through the rows of data
            while ( have_rows('menu_sections') ) : the_row();

                // display a sub field value

                $menu.= '<h2>' . get_sub_field('section_title') . '</h2>';
                if ( have_rows('sections_items'));

                    $menu.= '<table><thead><tr><td class="ja_name">Name</td><td class="ja_description">Description</td><td class="ja_price">Price</td></tr></thead>';

                    while (have_rows('section_items') ): the_row();

                        $menu.= '<tr><td>'.the_sub_field('dish_names').'</td><td>'.the_sub_field('dish_description').'</td><td>$ '.the_sub_field('dish_price').'</td></tr>';

                    endwhile

                    $menu.= '</table> ';

            endwhile;

         else : 

            // no rows found

        endif; ?>
        $menu.= '</div>';
    // Code
    return $menu;       
}
add_shortcode('testimonials', 'menu_loop');

using this code it shows syntax error, unexpected '$menu' (T_VARIABLE), expecting ';'

1 Answer 1

1

You have forgotten a semicolon after your endwhile on line 21.

2
  • after adding ; . still shows Parse error: syntax error, unexpected end of file
    – raja
    Dec 15, 2016 at 15:30
  • @raja There's something else wrong in your file then, something I can't see. And this Q was flagged as off-topic. Dec 16, 2016 at 7:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.