Get post featured image id with $wpdb

Haven’t tested it, but this should work: SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, wpcflat.meta_value AS latitude, wpcflong.meta_value AS longitude, 6371 * 2 * ASIN ( SQRT (POWER(SIN(($lat – wpcflat.meta_value)*pi()/180 / 2),2) + COS($lat * pi()/180) * COS(wpcflat.meta_value *pi()/180) * POWER(SIN(($long – wpcflong.meta_value) *pi()/180 / 2), 2) ) ) AS distance, wpcfthumbnail AS thumbnail_id; FROM $wpdb->posts LEFT JOIN … Read more

Only show featured image on exerpt and exclude images in post

you need to change the_content(‘Read more’); to the_excerpt(); Then in your functions.php file add_filter(‘excerpt_more’, ‘custom_read_more_link’); function custom_read_more_link($more) { return ‘<a href=”‘get_permalink().'”>Read More</a>’; } Also make sure that you’re calling wp_reset_query() after the while loop. This will achieve what you’re trying to do. A personal suggestion: Please don’t use query_posts, instead create a new instance of … Read more

How can I get the featured image or the first image for a post/page and display it as a banner?

You can use the featured image (or featured thumbnail) for this type of functionality. You can control which size of the image you use… it doesn’t have to be the “thumbnail” size. From the codex: get_the_post_thumbnail(get_the_ID(), ‘thumbnail’); // Thumbnail get_the_post_thumbnail(get_the_ID(), ‘medium’); // Medium resolution get_the_post_thumbnail(get_the_ID(), ‘large’); // Large resolution get_the_post_thumbnail(get_the_ID(), ‘full’); // Original resolution get_the_post_thumbnail(get_the_ID(), … Read more

Smaller thumbnail in the_content

I suspect you may be unclear about the code and features you are referring to and therefore about what you are asking. If you are trying to change the size of the thumbnail for an image you are inserting in the content area then you would change this in the Settings under Media as marikamitsos … Read more

How can I access a post’s feature image outside the loop?

On a single post page the $post variable should work for you. It is set well before the page header prints. You will need get_post_thumbnail_id and wp_get_attachment_image_src if (is_single()) { $thumbid = get_post_thumbnail_id($post->ID); $imgsrc = wp_get_attachment_image_src($thumbid); $src = $imgsrc[0]; // wp_die(var_dump($src)); // debugging/confirmation } I don’t know how your theme is written or how that … Read more