0

I am getting this error after loading my php page:

Parse error: syntax error, unexpected end of file in /Applications/XAMPP/xamppfiles/htdocs/wordpress2/wp-content/themes/annonciation/page-42.php on line 77

I could understand that it means that I have opened a certain bracket or parenthasis somewhere, and didn't close it, but I can't for the love of god find it! Here is my code:

<?php get_header();?>
<div id="container">
<!-- Glossaire -->
<p class="titrep" style="padding-top:192px;">- Glossaire -</p>

<div id="alphabet">
  <ul>
    <?php
foreach(range('A','Z') as $i) {?>
 <li>
  <?php echo $i;?>
 </li> 

<?php

if($i=='Z')
      {
        break;
      }
    else{
    ?>
    <li>.</li>
    <?php }
  }

?>
  </ul>
</div>

<div id="mots">
<?php //$test=new WP_Query(array('post_type'=>'mots')); ?>

<?php //while ( $test -> have_posts() ) : $test -> the_post();?>

<?php 

$args = array(
    'post_type'=> 'mots',
    'lettres'  => 'alpha',
    'order'    => 'ASC'
    ); 

$the_query = new WP_Query( $args );
if($the_query->have_posts() ) : {
  while ( $the_query->have_posts() ) : $the_query->the_post(); 

 //some code that is sure not making the error (i removed it and still getting the error)

 endwhile;
}?>

</div>
<?php get_footer(); ?>

what could the problem be?

| improve this question | | | | |
  • What code lies on Line 77 ? And should lettres be letters in your 2nd WP_Query argument? – Howdy_McGee Apr 24 '14 at 21:49
  • line 77 is the end of my document, so nothing there, and no, it shouldn't be letters, that's how my taxonomy is called in wordpress – user1438482 Apr 24 '14 at 22:07
1

I just want to add to the two answers given on this matter. It is important to know that if you use

if($the_query->have_posts() ) :

you will need to close that with

endif;

otherwise you will also get the same parse error as described.

| improve this answer | | | | |
1
if($the_query->have_posts() ) : {

Curly braces or colon/end syntax? Pick one.

Also, here's some recommended reading.

| improve this answer | | | | |
0

Here is the reference Doc for Loop in WordPress, from that if you want to use : then no need to use {}. you can use one of them at same time.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.