WordPress showing image as thumbnail without using thumbnail
Replace get_the_image function get_the_image( array( ‘meta_key’ => … For the_post_thumbnail function: the_post_thumbnail( $size, $attr );
Replace get_the_image function get_the_image( array( ‘meta_key’ => … For the_post_thumbnail function: the_post_thumbnail( $size, $attr );
Got it working by removing the <a href> from the image. This is the proper way of doing a responsive image with a link: <a href=”https://wordpress.stackexchange.com/questions/212844/<?php the_permalink(); ?>”> <picture> <source srcset=”https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/<?php echo get_template_directory_uri(); ?>/img/noimg-499px” media=”(max-width: 599px)”> <source srcset=”https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/<?php echo get_template_directory_uri(); ?>/img/noimg-120×90.jpg” media=”(max-width: 767px)”> <source srcset=”https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/<?php echo get_template_directory_uri(); ?>/img/noimg-220×116.jpg”> <!– fallback –> <img srcset=”https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/<?php echo get_template_directory_uri(); … Read more
You can use get_post_format($post_id) to retrieve each post’s format, then you can assign a class to each post based on it’s format. Once you have that, you only need to define said classes to, for example, show an icon overlay on the ::after pseudo-element of the posts. To obtain consistency between widgets, category pages, etc. … Read more
After add_post_meta($post_id, ‘_standard_image’, trailingslashit($uploaddir[‘url’]) . $filename); paste set_post_thumbnail($post_id, $attach_id); What this is doing is taking the attachment that is created in this function and adding it as a featured image. Hope that helps.
The code you are using is correct. The problem is that you are looking at thumbnails that have already been created. As @Loius mentioned you will need to use Regenerate Thumbnails to see the effect. Why core has not implemented this is beyond me.
You’ll have to code the output in the manner you want to display it. However you’ll have to generate the image link prior to the html part. Save the image in a variable $bgimage1; make the list using li and in the list item backgroun-image: <?php echo $bgimage1; ?>
What am i missing? ‘tag’ may be a valid argument for get_posts() via WP_Query, but requires the tag slug in that case. Try using ‘tag_id’ instead. get_posts() apparently enables ‘category’, but expects the the ID, even though in WP_Query the same argument is ‘cat’ (vs. ‘category_name’, et al). A little confusing, perhaps, altogether. I know … Read more
While you might believe that you have an error in WordPress, the actual problem actually is on facebooks end. When they already have an image, you need to force a rescrape (iirc) via their Open Graph Debugger(?). facebook caches images of various sizes by Url. Meaning that if you already served an image, they already … Read more
Use the following CSS to target only the banner image on single posts: body.sinlge .size-banner-image { width:100%; } This will only work if your <div class=”container”> element is not restricted in its width, else the banner will only stretch to the container width.
As you are storing posts IDs in meta fields of another post (let’s call this post “the main post”), you can get that meta field and if it is empty, just avoid the use of get_the_post_thumbnail(). (For the next examples, I suppose that you are stroing one post ID in one meta field of the … Read more