最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Parse Error: unexpected '}' while creating Shortcode with Loop

programmeradmin2浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 4 years ago.

Improve this question

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.

Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 4 years ago.

Improve this question

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.

Share Improve this question asked Oct 5, 2020 at 11:24 marvinpoomarvinpoo 3033 silver badges18 bronze badges 3
  • 2 Correct enwhile typo to endwhile and everything should be ok. – Ivan Shatsky Commented Oct 5, 2020 at 11:37
  • 1 @IvanShatsky can you post that as an answer? I can't give you upvote rep points for a comment :( – Tom J Nowell Commented Oct 5, 2020 at 11:55
  • @IvanShatsky oh my god! Thank you so much. It's always the tiniest things that end up making me lose my hairs. Thank you so much. Would appreciate it if you post this as an answer so I can upvote and mark it as correct. – marvinpoo Commented Oct 5, 2020 at 12:06
Add a comment  | 

1 Answer 1

Reset to default 3

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.

发布评论

评论列表(0)

  1. 暂无评论