Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
1  
Maybe some stray whitespace at the end of loop-event-details.php? –  t31os Mar 29 '11 at 15:09
    
+1 @t31os. Try to just write it piece per piece again into a new file and see what happens. –  kaiser Mar 29 '11 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 Mar 29 '11 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? –  Chip Bennett Mar 29 '11 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 Apr 6 '11 at 13:51
show 6 more comments

1 Answer

up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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