4

I can't seem to find the syntax error. here is the problematic code:

<div class='related_row'>
                    <?php
                        foreach($postList as $post):
                            setup_postdata( $post ); 
                    ?>
                            <div class='related_product'>
                                <?php if(has_post_thumbnail() ) : ?>
                                    <div class='related_image'>
                                        <a class='service_overlay' href='<?php the_permalink(); ?>'></a>
                                        <a class='service_page' href='<?php the_permalink(); ?>'><?php the_post_thumbnail(); ?></a>
                                    </div>
                                <?php else: ?>
                                    <div class='related_image'>
                                        <a class='service_overlay' href='<?php the_permalink(); ?>'></a>
                                        <a class='service_page' href='<?php the_permalink(); ?>'><img src="<?php get_bloginfo() ?>/wp-content/uploads/2013/08/header_image.png" alt='Service image' /></a>
                                    </div>
                                <?php endif; ?>
                                <div class='related_title'>
                                    <a href='<?php the_permalink(); ?>'><?php the_title(); ?></a>
                                </div>
                            </div>
                            <?php $counter++; ?>
                            <?php if($counter % 3 == 0 && $counter < $total ): ?>
                    </div>
                    <div class='related_row'>
                            <? endif; ?>
                            <?php
                                endforeach;
                                wp_reset_postdata();
                            ?>
                    </div>

I've been staring at this bit of code for the past 20 minutes and can't seem to spot it. I would really appreciate it if someone could point it out please.

0

1 Answer 1

7

If you've not got "short tags" switched on, the error is on line 26 of the sample above:

<? endif; ?>

Should be

<?php endif; ?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.