2

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.

3 Answers 3

2

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'); ?>
0
3

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' );
1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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