0

I have a loop template called loop-event-details.php where I have code to display each event.

My main page template is called events-page.php. I use the following code to include the loop template:

get_template_part( 'loop', 'event-details' );

I have also trying this code:

include(TEMPLATEPATH . '/loop-event-details.php');

However, when viewing a page it always complains about parsing error:

Parse error: syntax error, unexpected T_ENDWHILE in /<my_templatepath>/loop-event-details.php on line 1

The loop isn't on line 1, but line 15. The code in the loop file is correct, because when I copy and paste all the code from the loop file into the page file it all works. As soon as I try to include it with either contract (get_template_part() or include()) it doesn't work and always complains about line 1.

Any tips and help would be hugely appreciated.

Thanks, Dasha

WP 3.1.0

PHP Version 5.2.6-1+lenny9

11
  • 1
    Maybe some stray whitespace at the end of loop-event-details.php?
    – t31os
    Commented Mar 29, 2011 at 15:09
  • +1 @t31os. Try to just write it piece per piece again into a new file and see what happens.
    – kaiser
    Commented Mar 29, 2011 at 17:03
  • @kaiser did that, still the same :S soo confusing! Btw, I've got the same set up on my local machine (PHP 5.3.1) and it works alright. But displays that error on the online dev site with PHP Version 5.2.6-1+lenny9
    – dashaluna
    Commented Mar 29, 2011 at 17:16
  • 1
    Try including a completely empty loop-event-details.php using get_template_part(), and see if you still get the error? Commented Mar 29, 2011 at 20:11
  • 1
    @DashaLuna: You can write an answer yourself and accept it. You won't get a reputation increase, but it will mark the question as answered.
    – Jan Fabry
    Commented Apr 6, 2011 at 13:51

1 Answer 1

0

I've created a new file, specified the encoding as "UTF-8" and retyped everything by hand - no copy/paste from the old file. Took a while, but all works now. It must have been some encoding errors playing up.

Thanks to everyone who helped: @t31os, @kaiser, @Chip Bennett

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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