Articles of post thumbnails

Modify featured image URL at runtime

Simple question: I know this can be achieved with a hook somewhere, but I’m having trouble tracking down exactly where I need to look to implement it. Basically, I need to hook into the featured image / thumbnail hook and update the image URL on the fly. Can someone lend a hand on how I […]

Can I prevent get_the_post_thumbnail from falling back to the global post ID?

I have a post type that contains meta boxes. These metaboxes allow a user to select an item from a dropdown menu. All these items are IDs for other posts. So in the theme, I am using get_the_post_thumbnail to retrieve the featured image from the post ID retrieved from these metaboxes. It works. What doesn’t […]

Else/If Statement to Display Photo Descriptions

I am building a news WordPress theme and using the Description for thumbnails to display who the photo is credited to on the website. I am then placing the credits in the Description on top of the photo using the following code. However, when the photo has no Description/credit, I do not want the description […]

Static news page has for thumbnail the featured image of the first posts

So I have a static page for the news page in wordpress, and its featured image as a breadcrumb image. I query it with this: <?php the_post_thumbnail_url(get_option(‘page_for_posts’)); ?>. The problem is this function for whatever reason outputs the featured image of the first post instead of the featured image for the posts page. My entire […]

Get thumbnail image according to the screen

I need to retrieve the featured image according to the screen type. For tablet and mobile medium size and for desktop large. How can I know the user’s device type on server side to retrieve the appropriate image size? (In the example I use the theme API but of course I can use WordPress native […]

Thumbnails in ACF Query Results

I’m using pagelist_ext to list all pages under a specific category: The list was getting long, so I created some additional pages that add another level of filtering by querying ACF meta info, e.g., This is all working fine, but ideally, the styling of the query pages would match the /bands/ page. I’m […]

Featured image size in column

I have a featured image preview in column view in my Custom Post Types. Now I want to change the size of it. This is my code: add_filter(‘manage_posts_columns’, ‘add_img_column’); add_filter(‘manage_posts_custom_column’, ‘manage_img_column’, 10, 2); function add_img_column($columns) { $columns[‘img’] = ‘Featured Image’; return $columns; } function manage_img_column($column_name, $post_id) { if( $column_name == ‘img’ ) { echo get_the_post_thumbnail($post_id, […]

get_post_thumbnail does not display thumbnail

I’m trying to get a specific post’s thumbnail by using the post’s ID. I have this code snippet in my index.php file <?php get_the_post_thumbnail(64 , ‘post-thumbnail’, array( ‘class’ => ‘img-format-big’ ) ); ?> It doesn’t return any image/thumbnail at all. Anything wrong with the code?

False Positive on has_post_thumbnail

Within the loop, for a post (of custom post type) which does not have a featured image: has_post_thumbnail() (with or without specified $post->ID) is returning true, while get_the_post_thumbnail(), also with our without the $post->ID returns an empty string. The loop: $args = array( ‘post_type’ => ‘customs’, ‘post_status’ => ‘publish’, ‘fields’ => ‘id’, ‘posts_per_page’ => -1 […]

the_title() is not displaying over the_thumbnail

With the static html/css title that i have inside h1, is displaying over image, but when i use the_post_thumbnail(); with the_title();. Title moves above the image What may be the issue? <div class=”col-sm-6 col-md-4 padding-fixation”> <?php $portfolio_home = new WP_Query(‘cat=1’); ?> <?php while($portfolio_home->have_posts()) : $portfolio_home->the_post(); ?> <div class=”image-portfolio” data-section=”office”> <div class=”img-block”> <img class=”img-responsive” src=”<?php the_post_thumbnail(); […]