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 portfolio type theme. Each page has a post thumbnail. I have a home page where I have each post thumbnail in a ul list The list is then floated to create a grid. I need a name to go with each thumbnail. I'm using this code to get the post thumbnails caption. I'm trying to put the caption in a span in the li, I can then move the span below the image.

My problem is the spans all appear behind the last image on the right of the grid.

I have tried all css to try and move them to there li but they won't

In the source code the spans appear in the correct li.

Sorry I don't have an example to show - working locally. If an example is needed I could tomorrow.

    <ul>

            <?php

                $site_args = array(
                    'post_type' => 'page',
                    'category_name' => 'sites',
                    'order' => 'asc'
                );

                $theSites = new WP_Query($site_args);

                if($theSites->have_posts()):
                    while($theSites->have_posts()):
                        $theSites->the_post();

                $thumbnail_id    = get_post_thumbnail_id($post->ID);
              $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));

              if ($thumbnail_image && isset($thumbnail_image[0])) {
                $caption = '<span class="caption">'.$thumbnail_image[0]->post_excerpt.'</span>';
              } 

            ?>

            <li class="siteLink"><span><?php echo $caption; ?></span><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></li>

            <?php
                endwhile;
                endif;
                wp_reset_postdata();
            ?>

        </ul>
share|improve this question
    
CSS questions are off-topic I'm afraid - please see the FAQ. –  vancoder Apr 10 '13 at 16:17
    
It's not a css question. It's the code that is moving the spans. I was just trying to move it back with css –  user668499 Apr 10 '13 at 16:21
    
The spans actually appear outside the lis in the generated source code of the page? If not, this is a CSS question. –  s_ha_dum Apr 10 '13 at 16:30
    
The span appear inside the li in the source code. Is that CSS ? –  user668499 Apr 10 '13 at 16:52
1  
This is a CSS question. –  Chip Bennett Apr 10 '13 at 17:00

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.