get_post_thumbnail_id() not getting correct featured image after post edited
get_post_thumbnail_id() not getting correct featured image after post edited
get_post_thumbnail_id() not getting correct featured image after post edited
Show a featured image with “Link” Post Type?
Neither, they are just as fast as each other, both are using information that has already been fetched in advance. This is micro-optimising. Functions such as is_front_page or is_singular etc etc are just looking up variables already set in the main query object. Likewise functions such as has_post_thumbnail etc are looking up data that has … Read more
I’ve just found the reason why: the image is smaller than the thumbnail dimensions. That’s the reason why.
Got it – update_post_meta has to be used for _wp_attachment_image_alt
To unset all default image sizes in WordPress using PHP you can use this function: add_filter( ‘intermediate_image_sizes’, ‘remove_default_img_sizes’, 10, 1); function remove_default_img_sizes( $sizes ) { $targets = [‘thumbnail’, ‘medium’, ‘medium_large’, ‘large’, ‘1536×1536’, ‘2048×2048’]; foreach($sizes as $size_index=>$size) { if(in_array($size, $targets)) { unset($sizes[$size_index]); } } return $sizes; } Alternatively, you can also unset default images by going … Read more
Right before image subsizes are created, there’s a filter called intermediate_image_sizes_advanced that lets you modify the list of sizes. Here’s code that you could expand on — right now it just removes the thumbnail as a proof of concept: function remove_image_sizes_before_generation( $new_sizes, $image_meta, $attachment_id ) { $width = $image_meta[0]; $height = $image_meta[1]; // … Calculate aspect … Read more
You can enable featured image for pages (and other post types) by using the line below. This goes in your functions.php file. add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘page’ ) ); If you’re not comfortable with editing theme files then you should contact your theme developer. If featured images are not enabled by default in your theme … Read more
You can update the way image is displayed in template. in the page loop it will have something like this: <?php the_post_thumbnail(); ?> This grabs the featured image. You can wrap that in a conditional statement to check for whatever you like. This would show it in every category apart from catgory 3. <?php if … Read more
Off top of my head here’s two possible solution concepts. 1) Just run the custom loop (I meant to type, query) again and this time use it with only the_post_thumbnail. <?php if ($myposts->have_posts() ) : ?> <div class=”image-wrapper e-in”> <?php while ($myposts ->have_posts() ) : $myposts ->the_post(); ?> <div class=”image “> <!–Post Iamge Will Show … Read more