• The homepage just shows the featured images of posts but I’d like to show them in different sizes depending on the category the post is in.

    I guess it’s a If Else script in functions.php to define the difference but I have no idea how and couldn’t find a plugin to do it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Nilles01

    (@nilles01)

    So far I have this but it’s not working.

    <?php if ( is_home() ) : /* Display Excerpts for Home */ ?>
    
    	<?php has_post_thumbnail()? $birdsite_image_tag = 'has-image' : $birdsite_image_tag = ''; ?>
    
    	<li id="post-<?php the_ID(); ?>" <?php post_class($birdsite_image_tag); ?>>
    		<?php if(has_post_thumbnail()): ?>
    			<div class="thumbnail">
    				<?php if ( in_category('klein') ) {
    				the_post_thumbnail('medium'); ?>
    				<div class="more-link"><a>"><?php _e( 'more', 'birdsite' ); ?></a></div>
    			</div>
    <?php else { ?>
    				<?php the_post_thumbnail('large'); ?>
    				<div class="more-link"><a>"><?php _e( 'more', 'birdsite' ); ?></a></div>
    		<?php endif; ?>
    		<?php endif; ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I get “Parse error: syntax error, unexpected T_ELSE in /home/WEBSITE/wp-content/themes/birdsite/content.php on line 18” as an error

    Thread Starter Nilles01

    (@nilles01)

    Now I have this

    <?php
    /*
    The default template for displaying content. Used for both single and index/page/archive/search.
    */
    ?>
    
    <?php if ( is_home() ) : /* Display Excerpts for Home */ ?>
    
    	<?php has_post_thumbnail()? $birdsite_image_tag = 'has-image' : $birdsite_image_tag = ''; ?>
    
    	<li id="post-<?php the_ID(); ?>" <?php post_class($birdsite_image_tag); ?>>
    		<?php if(has_post_thumbnail()): ?>
    			<div class="thumbnail">
    <?php
    if ( in_category('klein') ) {
     the_post_thumbnail('medium');
    } else {
      the_post_thumbnail('large');
    }
    ?>
    				<div class="more-link"><a href="<?php the_permalink(); ?>"><?php _e( 'more', 'birdsite' ); ?></a></div>
    		<?php endif; ?>

    Now I added a post in the category ‘klein’ but the image on the homepage still has the same size. How do I define multiple thumbnail sizes?

    Hi Nilles01 — did you every resolve the multiple sized images issue you had?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different sizes featured images depending on category’ is closed to new replies.