Jump to content

Recommended Posts

can some one help me with this code I'm getting a Parse error: syntax error, unexpected T_ENDWHILE error code on the last line of code. source code below

 

 

<?php while ( have_posts() ) : the_post(); ?>


                   
                      <h1><?php the_title(); ?></h1>
                      
<?php get_template_part( 'content', 'page' ); ?>


                    </div>


<?php thinkup_input_allowcomments(); ?>






<?php endwhile; wp_reset_query(); ?>
              
                  <?php $mytrails = new WP_Query(array( 
                               'post_type' => '$mytrails'
                          )); ?>
                   <?php endwhile; ?>
Edited by mac_gyver
code tags please

'unexpected T_ENDWHILE' really means 'Dude, I see an 'endwhile' and I didn't expect it at all... what the hell is that?'. Sometimes, those error messages means that you are missing a ';' character at the end of a line and then PHP sees the next 'statement' (which is not a ';') and will spit this error.

 

But, like ParvinS said, in your case, you have two 'endwhile' and just one 'while loop'. PHP saw your last 'endwhile' and tought 'what the hell is that? I didn't see any 'while' and now you want to end it?'.

You know how you can avoid those errors? Proper formatting.

 

No offense, but this is a mess even for a Wordpress template. Indentation and visual structuring isn't just nice-to-have. It's a major part of writing correct code. If you you write a mess, then you first confuse other readers, then yourself and finally the parser. You've reached the last stage.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.