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 am trying to call in all posts in the current category, showing their thumbnail or 'featured image'. The code below does not work, it throws out a syntax error...

            <?php $temp_query = $wp_query; ?>
            <?php foreach(get_the_category() as $category) {
                $cat = $category->cat_ID; }
                query_posts('orderby=date&cat=' . $cat . '&order=ASC&posts_per_page=-1''); 
            ?>
            <?php while (have_posts()) : the_post(); ?>
                    <div class="page-thumb-wrap-single">
                        <?php
                            if ( has_post_thumbnail() ) {
                                    the_post_thumbnail();
                                } else {
                                        echo '<img src="#" alt="Something Went Wrong?" title="Sorry - Something went wrong?" />';
                            }
                        ?>
                    </div>
            <?php endwhile; ?>

...however, this code does retrieve the thumbnail;

            <?php $temp_query = $wp_query; ?>
            <?php foreach(get_the_category() as $category) {
                $cat = $category->cat_ID; }
                query_posts('orderby=date&cat=' . $cat . '&order=ASC&posts_per_page=-1''); 
            ?>
            <?php while (have_posts()) : the_post(); ?>
                    <div class="page-thumb-wrap-single">
                        <?php the_post_thumbnail(); ?>
                    </div>
            <?php endwhile; ?>

Can someone explain to me what it is i am doing wrong and why this occurs? It may also help me answer another question;

How can i create a condition inside this call to say 'if post has tag... do... if post has other tag... do...'

Thanks guys!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

the two single quote marks (after the number 1) in this line (of the top posted code section) seem to be causing the error - there should only be one single quote; shown below:

query_posts('orderby=date&cat=' . $cat . '&order=ASC&posts_per_page=-1');  

it is just puzzling that your other code (with the same error) alledegly does work (?)

if this is not the cause: what was the exact syntax error message?

share|improve this answer
    
That double single quote mark seemed to be making things break - but only with the second code? Not it is corrected, there dont seem to be any errors, so thanks! –  Infocentre Jul 15 '11 at 8:28

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.