• Hey Folks,

    I added the thumbnails feature to my child theme and it works great.

    I have different posts pulling in different sections and was wondering if there was a way to change the sizes for the different categories?

    For ex I have a category called story which displays all the posts in that category. However the thumbnails size for this is different here than other category.

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • yup

    first you add_image_size……
    http://codex.wordpress.org/Function_Reference/add_image_size

    for whatever sizes you need, and then you call them where you need them.

    since its a category template you are after, you could either use conditionals
    http://codex.wordpress.org/Conditional_Tags
    to place them all within one template like:

    if category 1
    sthmbnail
    if category 2 different thumbnail
    else
    standard thumbnail

    Or you can make category specific templates
    http://codex.wordpress.org/Category_Templates

    Thread Starter dreeftwood

    (@dreeftwood)

    THANKS! 🙂

    Alittle confused though.

    if ( function_exists( 'add_image_size' ) )
    	add_theme_support( 'post-thumbnails' ); 
    
    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'the-waking-prince-thumb', 286, 126, false );
    }

    the-waking-prince is the slug of the category with the addition of “-thumb” right? This is what I added to my child themes function.php file.

    Is this correct so far?

    I would rather not used a category template since it is not much difference so that leaves me with conditional?

    that would be followed by

    is_category('the-waking-prince')
    so

    if (is_category('the-waking-prince') ) {
        what goes here?
    }

    for naming the image size, you can call it chicken-nuggets if you want. It’s not related to anything, other than needing to know the name to call the image. Anyway, here’s my thumbnail registration code for example from my functions.php:

    // THIS IS THUMBNAIL SUPPORT
    if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 75, 75, true ); // default post thumbnails
    	add_image_size( 'index-post-thumb', 75, 75 );
    	add_image_size( 'single-post-thumbnail', 150, 150, true ); // Permalink thumbnail size
    	add_image_size( 'title-image', 50, 27 ); // Title mini photo
    	add_image_size( 'shop-single-image', 700, 999 ); //Shop Single Product Image
    	add_image_size( 'member-thumb', 205, 100, true ); // Member Page Image
    }

    you can see I register thumbnail support, then I define the default thumbnail size, then I make my additional sizes

    Now for the conditional its:

    <?php if( is_category('the-waking-prince') ) : ?>
         <?php the_post_thumbnail('the-waking-prince-thumb'); ?>
    <?php elseif( is_category('chicken-nuggets') ) : ?>
         <?php the_post_thumbnail('chicken_thumb'); ?>
    <?php else : ?>
         <?php the_post_thumbnail(); ?>
    <?php endif; ?>

    so this says, if its the walking prince category, use the waking prince thumbnail, if it’s chicken nuggets, use the chicken thumb thumbnail, otherwise use the default thumbnail

    You can add as many elseif lines as you want

    now, in your conditional, there is a difference between is_category and in_category

    is_category means if the archive page for that category is displayed

    in_category means the post is in a certain category

    so code accordingly, and I hope I didn’t confuse you too much

    Thread Starter dreeftwood

    (@dreeftwood)

    so this is what I have in the functions.php

    add_theme_support( 'post-thumbnails' );
       // THIS IS THUMBNAIL SUPPORT
        if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 75, 75, true ); // default thumbnails
    	add_image_size( 'the-walking-prince-thumb', 286, 126, false ); // Story of the Story.
    	}
    	?>

    then in the template file (after the wp loop) I added:

    <?php if( is_category('the-waking-prince') ) : ?>
        	<?php the_post_thumbnail('the-waking-prince-thumb'); ?>
            <?php endif; ?>

    is this correct?

    well, in functions.php you can delete that very first line…. yu see it is identical to the fourth line.

    as for you loop stuff, you are saying if its in the waking prince category, display the thumbnail.

    That’s it. Is that correct? You only want a thumbnail in that categroy, otherwise nothing in its place? If so, you are good

    Also, you said after the loop. that code goes IN the loop, is that what you meant?

    Thread Starter dreeftwood

    (@dreeftwood)

    well, in functions.php you can delete that very first line…. yu see it is identical to the fourth line.

    OK, I was not sure about that.

    That’s it. Is that correct? You only want a thumbnail in that categroy, otherwise nothing in its place? If so, you are good

    Yes, I figure I can add more if need be.

    Yes I was not sure where to add that code?
    like so?
    <?php
    $wp_query = new WP_Query();
    if( is_category(‘the-waking-prince’) ) :
    the_post_thumbnail(‘the-waking-prince-thumb’);
    endif;
    $wp_query->query( array( ‘posts_per_page’ => get_option( ‘posts_per_page’ ), ‘paged’ => $paged ) );
    $more = 0;
    ?>

    I really appreciate your help!

    no not there, that is the start of your loop.

    then you have the code for displaying output.

    It goes in the loop, in the output area whereever you want the thumbnail to show.

    For instance it could go under the title stuff, or above the_content. You need to decide where in the flow of your content you would want the thumbnail and place it appropriately

    Thread Starter dreeftwood

    (@dreeftwood)

    Rev. Voodoo,

    thanks a bunch for your help. I still can’t get this thing to work right. I am using Thematic, so not sure if there are issues with how that deal is supposed to work. I found this

    add_theme_support('post-thumbnails');
    	set_post_thumbnail_size(128, 128, true ); // 128 pixels wide by 128 pixels tall, hard crop mode
    
    function my_post_title($title) {
    	if (is_category()) {
    		return get_the_post_thumbnail(NULL, 'thumbnail') . $title;
    	} else {
    		return $title;
    	}
    }
    add_filter('thematic_postheader_posttitle', 'my_post_title');

    And all it does is add an additional thumbnail. Not sure what I am missing here.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Customizing Post Thumbnails?’ is closed to new replies.