How to check the array of featured images IDs

This is solely a PHP question. But as birgire mentioned, you can use in_array(). So, change your code to this: $post_thumbnail_id = get_post_thumbnail_id(); if( in_array( $post_thumbnail_id, array(1, 2, 3 ) ) ) { echo ‘<span>Location</span>’; } The first argument is your value, the second one is the array you want to search in.

has_post_thumbnail gives always TRUE

Then you’re using it outside of the loop, try this instead: <?php if (has_post_thumbnail( get_the_ID() )) { get_the_post_thumbnail( get_the_ID(), array(80,80) ); } else { ?> <img src=”http://example.org/<?php the_title( get_the_ID() ); ?>” width=”80px” height=”80px” alt=”<?php the_title( get_the_ID() ); ?>”> <?php } ?> If you’re not inside of a WP_Query loop, then post-specific functions like has_post_thumbnail() the_title() … Read more

Using concatenate with WordPress Thumbnail

the_post_thumbnail function echoes the result and does not return anything. If you want to concatenate it this way, you should use wp_get_attachment_image instead. $list .= ‘<div>’. wp_get_attachment_image( get_post_thumbnail_id(), ‘post-thumbnail’ ) . ‘</div>’;

How to handle and keep image quality of featured image uploads

Several things could be impacting the image quality, but the biggest impact is calling the_post_thumbnail() without giving it a size. By default that will get the “thumbnail” image size, which by default is 150×150 pixels. Try this instead: the_post_thumbnail(‘full’, array(‘class’ => ‘ responsiveThumbnail’)); Then you’ll be pulling the full-size image rather than the autogenerated thumbnail. … Read more

Show a default image

Create “images” folder in current active theme the put “default-image.jpg” in that folder. <?php if ( has_post_thumbnail( ) ) { echo get_the_post_thumbnail( $page->ID, ‘image’ ); } else { ?> <img src=”<?php echo get_template_directory_uri().’/images/default-image.jpg’; ?>”/> <?php } ?> Use path according to the theme (parent or child). get_stylesheet_directory_uri(): url path to current Theme directory get_template_directory_uri(): url … Read more

How do I set “Upload Image” as detault “Set Featured Image” window?

WordPress exposes media upload component globally, as well the featured image modal with wp.media.featuredImage so developers can interact with it. FeaturedImage component uses the wp.media.frame which is a Backbone component, which has custom event attached to it. There’s not much documentation on it, you can check the source here. You can use the following snippet … Read more

MultiPostThumbnail and the_post_thumbnail

In code you posted you have issue with syntax – you should stick either with braces style or colons style, mixing them is not supported. if(class_exists(‘MultiPostThumbnails’) && MultiPostThumbnails::has_post_thumbnail(‘post’, ‘secondary-image’)) { MultiPostThumbnails::the_post_thumbnail(‘post’, ‘secondary-image’, NULL, ‘post-secondary-image-thumbnail’); } else { the_post_thumbnail(); }

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