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.

how i can add title to my featured image?

I’m not sure about your question, but the below code is more correct. $attr = array( ‘title’ => get_the_title(), ‘alt’ => ‘a nice view of the ocean’, ); echo sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/281220/%s”>%s</a>’, get_the_permalink(), get_the_post_thumbnail( null, ‘post-thumbnail’, $attr ) );

Default Featured Image from Post content

Ok guys.. I got it finally working with my below code. function wpse55748_filter_post_thumbnail_html( $html ) { // If there is no post thumbnail, // Return a default image global $post; $pID = $post->ID; $thumb = ‘large’; $imgsrc = FALSE; if (has_post_thumbnail()) { $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($pID),$thumb); $imgsrc = $imgsrc[0]; } elseif ($postimages = get_children(“post_parent=$pID&post_type=attachment&post_mime_type=image&numberposts=0”)) { foreach($postimages … Read more

Adding Images into API

from the support forum of that plugin: Your cpt may not be registered correctly. Try adding this to your functions.php (change “event” to your post type slug): add_filter( ‘register_post_type_args’, function( $args, $post_type ) { if( ‘event’ === $post_type ) { $args[‘show_in_rest’] = true; } return $args; }, 10, 2 ); or make sure that you … Read more

How do get post thumbnail into plugin?

I dont know where you are using/inserting this code, but maybe you need the current post ID. Try using get_the_post_thumbnail_url( <post-ID> ,<thumbnail-size> ); To get the ID of the current post you can for example use $current_id = get_the_ID();. Than you can try $src = get_the_post_thumbnail_url( $current_id ,’post-thumbnail’ ); to get the URL.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)