Parse Error: unexpected ‘}’ while creating Shortcode with Loop

I think either I am quite stupid today or just work-blind by this project but I’ve been trying to fix a little error a new shortcode is causing.

This is the code

<?php function reviewslide_function() {
    $output .= '
    <!-- Review Injection -->
    <div id="reviews" class="p-full">
        <div class="section_head">
            <span class="eyebrow">You about us</span>
            <h2>Customer Reviews</h2>
        </div>
        <div class="stars">
            <span class="material-icons">grade</span>
            <span class="material-icons">grade</span>
            <span class="material-icons">grade</span>
            <span class="material-icons">grade</span>
            <span class="material-icons">grade</span>
        </div>
        <div id="reviewbox">';
    $args = array(
        'post_type' => 'review',
        'posts_per_page' => 5,
        'order' => 'DESC',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    $output .= '
        <div class="review">'.
        the_content().
        '<span class="review_author">'. 
        bewerter_get_meta( "bewerter_name" ).
        '</span></div>';
    enwhile;
    $output .= '
    </div>
        <script>jQuery("#reviewbox > div:gt(0)").hide();
        
            setInterval(function() {
                jQuery("#reviewbox > div:first")
                .fadeOut(1800)
                .next()
                .fadeIn(2000)
                .end()
                .appendTo("#reviewbox");
            },  6000);
        </script>
        <div class="reviewbtn btn btn_blue arrow_r nosmooth">
            <a href="~GOOGLEREVIEWLINK~" target="_blank"><span>All Reviews</span></a>
        </div>
    </div>
    <!-- Review Exit -->';
    return $output;
}
add_shortcode('reviews', 'reviewslide_function'); ?>

This is the error thrown at me:

Parse error: syntax error, unexpected '}' in /html/wordpress-dev/wp-content/plugins/cpt-review/index.php on line 187

I am getting mad crazy trying to fix this, I just seem to be unable to find the error in here.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You have a typo in your code (enwhile instead of endwhile) so PHP is complaining because of non-closed while loop. Correct it and everything should be ok.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x