-5

i have error log

PHP Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) in /wp-content/themes/awaken/page.php on line 26

my page.php

get_header(); ?>
<div class="row">
<?php is_rtl() ? $rtl = 'awaken-rtl' : $rtl = ''; ?>
<div class="col-xs-12 col-sm-12 col-md-8 <?php echo $rtl ?>">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', 'page' ); ?>
                <?php if ( get_theme_mod( 'display_page_comments', 1 ) ) { // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || '0' != get_comments_number() ) : comments_template(); endif; } ?>
            <?php endwhile; // end of the loop. ?>
        </main><!-- #main -->
    </div><!-- #primary -->
</div><!-- .bootstrap cols -->
<div class="col-xs-12 col-sm-6 col-md-4">
    <?php get_sidebar(); ?>
</div><!-- .bootstrap cols -->
</div><!-- .row -->
<?php get_footer(); ?>

Please help! i have a 503 error, and think it's a problem

2 Answers2

1

Don't mix regular and extended syntax, especially when you've got horrible indenting. Note how the code looks WITHOUT all the repetitive/pointless php open/close tags:

while ( have_posts() ) : the_post();
   if ( get_theme_mod( 'display_page_comments', 1 ) ) { // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || '0' != get_comments_number() ) : comments_template(); endif; }
      endwhile; // end of the loop

since you commented out part of the if, you never close the {, which means your endwhile is trying to terminate a while which doesn't exist.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0

Do you see it? I do. You've commented out code and incidentally took the closing bracket to if( get_theme_mod with it. This is a simple syntax error.

<?php if ( get_theme_mod( 'display_page_comments', 1 ) ) { // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || '0' != get_comments_number() ) : comments_template(); endif; } ?>

Needs to be changed to

 <?php if ( get_theme_mod( 'display_page_comments', 1 ) ) { 
     // If comments are open or we have at least one comment, load up the comment template 
     if ( comments_open() || '0' != get_comments_number() ) : 
         comments_template();        
     endif; 
 } ?>

If you don't want the comments template, then just comment out //comments_template();

The reason for this is that the inline commenting you've added will comment out the entire line it doesn't pick and choose which parts it should comment out and which parts it should let the interpreter process.

Ohgodwhy
  • 49,779
  • 11
  • 80
  • 110