网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

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

GG网络技术分享 2025-03-18 16:12 6


问题描述:

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>

网友观点:

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) {

标签:

提交需求或反馈

Demand feedback