• hi

    I’m trying to use the_post_thumbnail with my own parameters, but it always comes out with the defaults. i’m building my theme on top of twentyten as a child theme.
    this is my code:

    add_image_size( 'jp-gallery-list',  500, 180, true );
    if (is_category()) {
    	global $post;
    	$args = array( 'numberposts' => 5, 'offset'=> 0, 'category' => get_query_var('cat') );
    	$myposts = get_posts( $args );
    	foreach( $myposts as $post ) :
    		setup_postdata($post);
    		?>
    		<a href="<?php the_permalink(); ?>">
    		<?php
    		if(has_post_thumbnail()) {
    			$thumb_attr = array(
    				'class'	=> "gallery-list-thumb",
    				'alt'	=> the_title_attribute(array('echo' => false) ),
    				'title'	=> the_title_attribute(array('echo' => false) ),
    			);
    			the_post_thumbnail('jp-gallery-list', $thumb_attr );
    		}
    		?>
    		</a>
    		<?php
    	endforeach;
    }

    however, the output is

    <a href="https://www.luciatallova.com/blur-minds-clear-sights/">
    <img src="https://www.luciatallova.com/wp-content/gallery/znova-nemozem-zaspat/thumbs/thumbs_165166_499474188633_99323968633_6311917_732718_n.jpg" alt="165166_499474188633_99323968633_6311917_732718_n" title="znova nemozem zaspat" class="wp-post-image ngg-image-1 " />
    </a>

    which is wrong – or rather default…

    thanks for comments!

  • The topic ‘the_post_thumbnail problem’ is closed to new replies.