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 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳