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.

Edit : ok everything works fine : i finally had to use taxonomies and get_terms, and putting everything in divs work better than lis. Thanks for your help.

Hi,
i have a problem with the categories and post thumbnail, my images are mixing up, the titles are OK, in the good order, but then the thumbnail of the first category goes under the second category title, and the second category thumbnail goes under the first title. I tried with "orderby" "name" on both get_categories or $second query but it's still the same : do you know how i could fix it?

        <?php
                        <div id="cat-diapo">
                    <ul>
                        <?php 
                        //$tout = wp_list_categories();
                        $tout = get_categories();
                        foreach ($tout as $tou){
                            $mon_id = $tou->cat_ID;
                            echo '<li>';
                            echo '<span>'.$tou->name.'</span>';
                            $argu = array ('cat'=>$mon_id);
                            $second = new WP_Query($argu);
                            while ($second->have_posts()) : $second->the_post();
                                $res = '<div class="sous-cat">'.the_post_thumbnail("mini", array("alt"=> the_post()->ID)).'</div>';
                            endwhile;
                            wp_reset_postdata();
                        }
                        echo '</li>';

and here's the markup :

        <div id="cat-diapo">

        <ul>

        <li><span>Andalousia</span>
        <img width="150" height="140" src="http://localhost:8888/espe/wp-content/uploads/2011/05/h.jpg" class="attachment-mini wp-post-image" alt="" title="h" />

        <li><span>Spain</span>
        <img width="150" height="123" src="http://localhost:8888/espe/wp-content/uploads/2011/05/Corida-65x811.jpg" class="attachment-mini wp-post-image" alt="" title="Corida - 65x81" />

        <li><span>Another post</span>
        <img width="150" height="213" src="http://localhost:8888/espe/wp-content/uploads/2011/05/p2-150x213.jpg" class="attachment-mini wp-post-image" alt="" title="p2" /></li>

So all the code php in my first post is wrapped by "ul" tags, and this gives me the code just above : this seems ok, but the image of "Andalousia" is under the title "Spain", and vice versa...

thanks a lot

share|improve this question
add comment

1 Answer 1

You seem to be generating broken markup by mixing stuff in and out of list item (<li></li>) tags. Try validating resulting markup and fix any errors produced.

share|improve this answer
    
thanks, what do you mean by "Try validating resulting markup and fix any errors produced" ? i checked the source code : everything seems ok, except only images are switching –  Paul_p Jun 1 '11 at 0:10
    
@Paul_p with tools such as validator.w3.org/unicorn for example. –  Rarst Jun 1 '11 at 7:39
    
thanks, unfortunately it did not show me any specific error. Do you know any test i could make to debug this? –  Paul_p Jun 1 '11 at 22:35
    
@Paul_p if you add sample of resulting markup to question that might help figuring out the issue you are having –  Rarst Jun 1 '11 at 22:37
    
i put the code in the post below –  Paul_p Jun 1 '11 at 23:15
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.