WordPress.org

Support

Support » Themes and Templates » [Resolved] Twentyeleven child-issue with thumbnail size on custom post type

[Resolved] Twentyeleven child-issue with thumbnail size on custom post type

  • I have created a child theme of twentyeleven and I am having issues with a custom post type’s thumbnails being created with the dimensions of 1000px X 288px. I know that this is the image size in the custom header function of the parent. I have added the following to my child function.php:

    if ( function_exists( 'add_theme_support' ) ) {
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 280, 210, true ); // Normal post thumbnails
        add_image_size( 'screen-shot', 720, 540 ); // Full size screen
    }

    My custom post type is being looped in a custom page template. I’ve also created a pastebin here:

    Any help is much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • keesiemeijer
    Moderator

    @keesiemeijer

    Let the parent theme set the default post thumbnail size (for the custom header function) and just add a new post thumbnail size in your child theme’s functions.php:

    add_image_size( 'new-size', 280, 210, true ); // new post thumbnail size

    If you’re on 3.4.1 you don’t have to check if the add_theme_support function exists.

    Now in your custom template change this:

    <?php the_post_thumbnail(); ?>

    to this:

    <?php the_post_thumbnail('new-size'); ?>

    http://codex.wordpress.org/Function_Reference/the_post_thumbnail

    sometimes you need to re-genarate your (old) post thumbnails to have the new image size take effect: http://wordpress.org/extend/plugins/regenerate-thumbnails/

    Only do this after a full backup (images and database)

    Thank you so much keesiemeijer!

    That is a much more elegant solution and way less obtrusive than what I was trying.

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Twentyeleven child-issue with thumbnail size on custom post type’ is closed to new replies.