ThemeShaper Forums » Thematic


Display a thumbnail, ONLY if the post has a post_thumbnail

(3 posts)
  • Started 11 years ago by Dopang
  • Latest reply from Chris
  • This topic is not resolved


  1. Dopang

    Hi.. First of all, sorry for my bad english.

    I want to display the post_thumbnail on the homepage by floating it to the left, while the title, meta, content, etc are floated to the right. Here's the image for example. And here's my function for the index section:

    function thumb_index_loop(){
           while ( have_posts() ) : the_post()  // Start the loop:
        // This is just what we decide to show in each post ?>
        <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    <?php if ( has_post_thumbnail()) { ?>
    	<div class="pic fl"><!--floating thumbnail to the left-->
    		<?php the_post_thumbnail(); ?></a>
     <?php	} ?>
    <div class="postfloater"><!--floating post elements to the right-->
         <?php thematic_postheader(); ?>
            <div class="entry-content">
    				<?php the_excerpt(); ?>
            <?php thematic_postfooter(); ?>
    <div class="clear"></div>
        </div><!-- .post -->
        endwhile; // loop done, go back up
    add_action('thematic_indexloop', 'thumb_index_loop');

    The problem is, when the post didn't have a thumbnail, the post elements still floated to the right. So what i want to do is make a conditional function that floated the post elements to the right when the post has a thumbnail, and show the post elements without the floater div when it didn't have a thumbnail.

    I always end up with syntax error, by doing trial and error with the conditional function (php if, else, etc..)

    Any ideas?

    Posted 11 years ago #
  2. why are you float the post elements to the right? what if you float them to the left?

    Posted 11 years ago #
  3. Put the whole stuff into that if stucture. Plus Else do the regular stuff without the floats.


    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.