duannao3402 2018-01-18 18:16
浏览 110
已采纳

Wordpress插件错误语法错误,意外'endwhile'[重复]

This question already has an answer here:

I've migrated a website across from a cheapo deluxe host over to my AWS Lightsail instance. Now everything works until I go to this page. It worked OK on the old host but on lightsail it's not working at all. I just get the Wordpress plugin Error syntax error, unexpected 'endwhile' on line 87 error.

I've tried everything I can think of and have spent a good few hours tinkering and Googling. I'm sure im missing a single } or { somewhere

PHP isn't my strong point so any help would be greatly appreciated.

Code below is the original file, without my tinkering.

Thanks everyone!

    <?php

get_header(); ?>

<div id="page-header">
    <div class="container"> 
        <div class="row">
            <div class="col-lg-12">
                <header class="page-header">
                    <h1>Meet the team</h1>
                </header><!-- .entry-header -->
            </div>  
        </div>
    </div>  
</div>  
<!-- page-header -->

<div id="content-container" class="team">
    <div class="container">

        <div class="row">

            <div class="col-lg-12">

                    <?php $projectloop = new WP_Query(array(
                                'paged'          => get_query_var('paged'),
                                'post_type'      => 'meet-the-team',
                                'paged' => $paged,
                                'posts_per_page' => 100,
                                'orderby'      => 'name',
                                'order'     => 'ASC',

                            )); ?>



                            <?php  $count = 0; while ( $projectloop->have_posts() ) : $projectloop->the_post(); 

                                if ($count == 0 || ($count % 3 == 0)) { ?>
                                    <div class="row">
                                <? } ?> 

                                     <div class="col-lg-4 team-member">
                                        <?php 

                                if ( '' != get_the_post_thumbnail() ) {?>

                                        <?php echo get_the_post_thumbnail(get_the_ID(),'team',array('alt' => get_the_title(),'title' => get_the_title())); ?>

                                <?php } else { ?>

                                        <img class="image" alt="<?php bloginfo('name'); ?>" src="<?php bloginfo('template_url'); ?>/images/team-member-default.jpg" alt="Face Dental">                                                                                                                                                                          
                                <?php } ?>

                                        <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                                        <p class="job-title"><?php the_field('job_title'); ?></p>

                                        <?php if(get_field('speciality')) { ?>
                                            <p>Special Interests: <?php the_field('speciality'); ?></p>
                                        <?php } ?>

                                        <?php if(get_field('gdc_number')) { ?>
                                            <p>GDC Number: <?php the_field('gdc_number'); ?></p>
                                        <?php } ?>

                                        <p>Work days: <?php the_field('work_days'); ?></p>
                                        <?php //the_excerpt ();?>
                                     </div> 

                              <?php $count++;

                                    if($count == 0 || ($count % 3 == 0)) { ?>
                                    </div>
                                <?php } ?>  


                        <?php endwhile; // end of the loop. ?>


                    <?php
                        $big = 999999999; // need an unlikely integer

                        echo '<div class="pagination">';
                        echo paginate_links( array(
                            'type' => 'list',
                            'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                            'format' => '?paged=%#%',
                            'current' => max( 1, get_query_var('paged') ),
                            'total' => $projectloop->max_num_pages,
                            'next_text' => __('»'),
                            'prev_text' => __('«'),
                        ) );
                    ?></div>

                </div>
            </div>
        </div>

    </div>
</div>
<!-- content-container -->

<?php get_footer(); ?>
</div>
  • 写回答

1条回答 默认 最新

  • dongmu1914 2018-01-18 18:23
    关注

    line 41 <? } ?> should be <?php } ?>

    you can also just use { to open while loop instead of :. Using : in your case is little messed up since your php is a mess with html

    Also when looking at the while ( $projectloop->have_posts() ) this isn't a while loop but rather if statement

    check this out http://php.net/manual/en/control-structures.while.php

    Your while loop needs a statement while ($count <= 10) {

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU