1

Want to use a different featured image size for a custom post type and exclude it from main blog loop. And also want to display it on specific page.

What will be the fastest way to achieve this? With code mess up and plugins?

Prefer a code snippet solution, but main issue it should work out-of-box, as fast solution is a priority.

Thanks in advance.

1

This might help - Set featured image size for a custom post type,

Just add a new image size

add_image_size( 'companies_thumb', 120, 120, true);

Then in the post type template for companies you just call the thumb you defined.

<?php the_post_thumbnail('companies_thumb'); ?>
1

Make a custom post-type template with the specific featured size in the template or appropriate css applied to the image.

1

I was also looking for a way to change the featured image size for a custom post type – even in the admin so you’ll se a correct preview when the image is inserted. This code will do the trick and hopefully this will help someone.

Put the code in functions.php of your child theme. Remember that your theme must support post thumbnails.

// Change Featured Image Size for Custom Post Type
function custom_post_type_featured_image_size() {
    add_post_type_support( 'your_custom_post_type', 'thumbnail' );
    set_post_thumbnail_size( width, height, true ); //true will crop image
}
add_action( 'init', 'custom_post_type_featured_image_size' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.