ThemeShaper Forums » Thematic

[closed]

How to display post thumbnails & custom HTML in the Loop

(2 posts)
  • Started 7 years ago by proto
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. proto
    Member

    Hello all,

    I'm trying to display my post thumbnails as part of my loop, in my functions I thought I had the correct code to enable them support for post-thumbnails here:

    // Add support for thumbnails
    add_theme_support('post-thumbnails');
    get_option('thumbnail_crop');
    add_image_size('slider_image', 940, 340, true);
    add_image_size('featured_image', 300, 150, true);

    Then in my loop I call the post thumbnails 'featured_image':

    function pixelwoo_loop_two() {
    
    	 query_posts ('category_name=featured&posts_per_page=2');
    $counter = 3;
    
      if (have_posts()) : while (have_posts()) : the_post(); ?>
    
        <div class="grid_4">
        <div id="post-<?php the_ID() ?>">
          <?php thematic_postheader();
          if ($counter == 2 && has_post_thumbnail()) {
            the_post_thumbnail('featured_image');
          } ?>
          <div class="entry-content">
    
    		<?php the_excerpt(); ?>
    
            <a href="<?php the_permalink(); ?>" class="more"><?php echo more_text() ?></a>
            <?php $counter++; ?>
    	</div><!-- post ID -->
        </div><!-- entry-content -->
      	 </div><!-- grid_4 -->
    
       <?php endwhile; else: ?>
        <h2>Eek</h2>
        There are no posts to show!
    
      <?php endif;}

    However, if you look at my webpage, it does not display:

    https://www.universalonewebdesign.com/bespoke-design-three/

    Any ideas why - sorry if it's very obvious - this loop is driving me loopy!! :)

    Also, is there a way to include some static non-dynamic html in my loop, eg:

    <div id="example">Here is example text</div>

    That does not break it?

    Any help greatly appreciated!

    Posted 7 years ago #
  2. actually i couldn't tell if it is displaying or not b/c there is nothing to differentiate it from everything else for me. just another reason i like to echo "bacon" ;)

    try replacing your query_posts line (and there is a space in it that doesn't belong) with

    $test = query_posts('category_name=featured&posts_per_page=2');
    print_r($test);

    need to know you are getting posts in your query before you can test anything else.

    also you seem so start the $counter at 3, then add one each time through the loop, but only show the_post_thumbnail if $counter==2, which will never, ever happen.

    there are examples of loops in the codex (and pretty much all over the internet. why not start w/ one that works and mod accordingly

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.