How to force WordPress to upscale images?

You can always use the full size, but if the issue is that your images don’t cover enough area, you can fix that with CSS and the background-size and object-fit parameters. This will let you use img tags that are larger than the source image, or background images smaller than their container, and allow you … Read more

get_the_post_thumbnail_url does not return anything if image size is set

The first parameter for get_the_post_thumbnail_url() is the post ID or post object, and not the image size which is actually the second parameter. So: // Instead of this: get_the_post_thumbnail_url( ‘thumbnail’ ) // You should use: get_the_post_thumbnail_url( get_the_ID(), ‘thumbnail’ ) // pass a post ID get_the_post_thumbnail_url( get_post(), ‘thumbnail’ ) // or post object // Or you … Read more

Recent posts on homepage: different thumbnail based on logged in status and post category

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() to restore … Read more

Thumbnail is showing outside its div instead of inside it

the_post_thumbnail() echo the output, hence that’s why the thumbnail is misplaced. To manually echo the output, you should use get_the_post_thumbnail() instead: echo ‘<div class=”post-image right”>’ . // wrapped get_the_post_thumbnail(null, ‘featured-portrait-large’) . ‘</div>’; Or you can instead do this: echo ‘<div class=”post-image right”>’; the_post_thumbnail(‘featured-portrait-large’); echo ‘</div>’;

Automatically add images to a menu

I guess you need this function get_the_post_thumbnail_url($menu->object_id); (provided menu item is not a custom link) $menu->ID is not the id of the post/page it is linking to. About calling meta yes it is also possible $image_url = get_post_meta( $menu->object_id, ‘meta_key’, true );