adding additional class to get the post thumbnail [duplicate]

Sorry for late reply, already fixed, i miss understood about array, so here the code that completely run as i want it. <?php $next_post = get_next_post(); next_post_link(‘%link’, get_the_post_thumbnail($next_post->ID, ‘prev_next_img’, array( ‘class’ => ’rounded-lg object-fill w-full max-h-full’ )) . ‘<h4 class=”text-center mt-2 lg:text-base text-sm no-underline text-black leading-snug font-medium”>%title</h4>’, false); ?> in function.php i put custome image … Read more

featured image background

You can try wp_get_attachment_image_src this for getting Feature Image URL. Here is the Full code. <?php function propertunity_featured_post() { $featured_post_id = 2860; $featured_post = get_post($featured_post_id); $featured_post_url = get_permalink($featured_post_id); $featured_post_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($featured_post_id, ‘thumbnail’) ); echo “<div class=”card”> <div class=”card-header” style=”background-color: #f8f8fc; overflow: hidden;”> <a href=”” . $featured_post_url . “”> <div class=”card__image” style=”background-image: url(” ” . … Read more

WordPress generate images size after upload

I see 2 problems in your last part. You didn’t add hook for the code. Without it, I doubt that the add_image_size function will be executed. I suggest you wrap it in another function and add to after_setup_theme hook with add_action function. I think the way you use function_exists is unnecessary. With the way you … Read more

Distinguish between page and post in function

By using post id you can get post type of current post/page. try below code. i have tested and it is working fine for me. add_filter( ‘admin_post_thumbnail_html’, ‘foo’,10,3 ); function foo( $content, $post_id, $thumbnail_id ) { if ( get_post_type( $post_id ) == ‘page’ ) { $content=”<p>foobar</p>” . $content; } else{ $content=”<p>barfoo</p>” . $content; } return … Read more

Hide Featured Image in AMP

Try this code: add_filter( ‘amp_post_template_data’, ‘xyz_amp_remove_featured_image’ ); function xyz_amp_remove_featured_image( $data ) { $data[‘featured_image’] = false; return $data; } More info about the amp hooks here https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/