How to display first post thumbnail as a background image of a widget?

Few notes: Just use the_title(); instead of echo get_the_title(); Use the_title_attribute() for title attributes. No need to override the global $wp_query when you use a secondary query. Then use wp_reset_postdata() after your secondary query loop. Use the_permalink() that escapes the permalink, instead of the unescaped echo get_permalink(); There’s the has_post_thumbnail() to check if the post … Read more

ACF – Add/update featured image (for videos) by field [closed]

This code will happen when you update the key name. File: wp-content/plugins/advanced-custom-fields/core/fields/_functions.php 193: foreach( array(‘key’, ‘name’, ‘type’) as $key ) 194: { 195: // run filters 196: $value = apply_filters(‘acf/update_value/’ . $key . ‘=’ . $field[ $key ], $value, $post_id, $field); // new filter 197: } Try to: print $value, $post_id, $field to understand what … Read more

Show preview of post changes on page

It is HTML and Javascript territory. For the image preview, you may need a input type=”file” with accept=”image/*” and onchange event handler for the preview and the javascript getElementById to get the image id to display for preview. Have a look at these examples. For the text preview part here is a fiddle link. It … Read more

Needs to add anchor tag in featured image to open in new tab

the_post_thumbnail() will return a full link to your image. Instead, use the_post_thumbnail_url(); to only fetch the URL: <?php if (has_post_thumbnail()) : ?> <a href=”https://wordpress.stackexchange.com/questions/255872/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>” target=”_blank”><img src=”<?php the_post_thumbnail_url(‘thumbnailnew2′); ?>” alt=”<?php the_title_attribute(); ?>”/></a> This will serve you nicely. And don’t forget the semicolons, too. Update 1 You have an unnecessary endif; causing … Read more

2 image size for post

WP image sizes apply to all images – there’s no way to tell WP, “only generate rectangular sizes when I upload a rectangular image; and only generate square sizes when I upload a square image.” So, you need to add (or customize an existing) image size for each scenario.