Set_post_thumbnail not resizing images

Setting the size itself does not crop the existing images. You need to regenerate the existing thumbnails too. There are a couple of plugins for this, but I personally downloaded and used Regenerate Thumbnails. Install the plugin, and head over to Tools > Regenerate Thumbnails. There you can regenerate thumbnails for images that exist in … Read more

Post thumbnail not showing in WP admin area for custom post type

I think it’s possible the 2 separate enabling statements may be interfering with each other. The purpose of having an array is to combine them into one enabling statement. Try the following in your functions file. Instead of: add_theme_support( ‘post-thumbnails’ ); add_theme_support( ‘post-thumbnails’, array( ‘customposttypename’ ) ); This: add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘customposttypename’ ) );

post_thumbnail_html only for specific thumb size

You’re getting the size as the $size as the 4th argument of your callback function. You just need to use an if statement to check it: function thumb_bookmark_html( $html, $post_id, $post_image_id, $size ) { if ( $size === ‘thumb-bookmark’ ) { $html=”<a class=”MyClass” href=”” . get_permalink( $post_id ) . ‘” alt=”‘ . esc_attr( get_the_title( $post_id … Read more

Woocommerce featured image of page – not product

Thanks to you I tried this on my functions.php It worked, but also had to get the ID of the page, in my case 4. add_action( ‘woocommerce_before_main_content’, ‘woocommerce_category_image’, 2 ); function woocommerce_category_image() { if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_term_meta( $cat->term_id, ‘thumbnail_id’, true ); $image = wp_get_attachment_url( $thumbnail_id ); if … Read more

If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?

Here’s what you can do: Delete the Old Thumbnails Download and install the Thumbnail Cleaner plugin. This plugin will delete all of your current thumbnails. You can do this manually by writing a PHP snippet that detects thumbnails and deletes them, but it’s not really that necessary. Resize the Original Images Once you have deleted … Read more

wordpress get_the_post_thumbnail can’t set size

1- In functions.php add_theme_support( ‘post-thumbnails’ ); add_image_size(‘my-custom-thumb’, 210, 210, true); 2- Note (https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size) This function will not resize your existing featured images. To regenerate existing images in the new size, use the Regenerate Thumbnails (http://wordpress.org/plugins/regenerate-thumbnails/) plugin. 3- Then wp_get_attachment_image_src(get_post_thumbnail_id($id), ‘my-custom-thumb’) If that doesn’t work, then I would probably triple check if there is an image … Read more

How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts

Or is it because im trying to add it to the css class .has-post-thumbnail which is applied to all posts? Yes, set_featured_background() gets first post from the loop and add .has-post-thumbnail to styles. All posts that have thumbnail (with class .has-post-thumbnail) will have the same background. Try setting the background in the template file responsible … Read more

Featured images not displaying at full resolution

Without seeing your theme setup you could try this. If you don’t need that size of image, set the thumbnail size and then regenerate your thumbnails. Keep in mind this will set this size image for all thumbnails, this may not be what you want. Add the following to your functions.php. set_post_thumbnail_size(560, 315); More info … Read more