How do I display the featured image from an image gallery using a reference in code? (example within)

UPDATED First, let’s create a new image size. We could update one of the existing sites, but we’ll just add a new one for experience sake. Open up your functions.php file and add the following: if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘new-size’, 500, 500, true ); // Cropped add_image_size( ‘another-size’, 400, 600 ); … Read more

Using catch_the_image to get the thumbnail size

You can add your own named image size by adding code to your functions.php. Something in the line of add_theme_support(‘post-thumbnails’);//might not be necessary add_image_size(‘front-end-150’, 300, 300); Now you should be able to use in your catch_that_image() wp_get_attachment_image($post->ID, ‘front-end-150′) for all newly uploaded images. Your past images don’t have the front-end-150, so you might want to … Read more

How to check all items in a loop have post thumbnail?

Before you do your output, do something like this: $no_thumbnails = true; foreach( $shows_sales as $p ) { if( has_post_thumbnail( $p->ID ) ) $no_thumbnails = false; } Then in your loop you can do something like this: <?php if( $no_thumbnails === true ) : ?> <!– Your output here –> <?php endif; ?>

WordPress 3.3.1 not cropping featured image

By default, the_post_thumbnail() $size parameter is ‘post-thumbnail’. You can set that by adding this line to your functions.php : set_post_thumbnail_size(125,125,true); If this still doesn’t update your image’s size, you may need to use a plugin like “Regenerate Thumbnails.” Alternately, you can set the image to use one of the Media Options-defined sized by passing a … Read more

Create an instance of add_image_size

When you upload an image, it’s saved, and a copy is created for every image size, resized to the appropriate dimensions. When you specify a set of dimensions manually, e.g. wp_get_attachment_image_src($id, array(57, 57)) the 57×57 dimensions are compared to the image sizes, and the nearest image size is chosen and that image is returned. So … Read more

WordPress featured image url rendering incorrectly when page is loaded causing image to break

I’d recommend taking a look at the database. 1) check the upload_path option and correct directly if needed (well, this one can be altered here too: wp-admin/options.php) SELECT * FROM `wp_options` WHERE `option_name` = ‘upload_path’ 2) check the guid of the attachments and use this plugin if needed SELECT guid,post_mime_type FROM `wp_posts` WHERE `post_type` = … Read more

Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out

You’ve got some basic syntax problems. Your elseif statement wasn’t actually checking anything and wasn’t properly wrapped in parenthesis. The logic more appropriately checks if the first condition is true, then if the second condition is true, and finally if all else fails, display the hard coded image. <?php $meta_box_topbanner_url = get_post_meta( $post->ID, ‘meta_box_topbanner_url’, true … Read more

Show different size featured images (the_post_thumbnail) for 1st, 2nd and 3rd posts?

Just use the $count variable that you are incrementing: <?php $count = 0; $some_featured_posts = new WP_Query(array(‘category_name’ => ‘apps’, ‘posts_per_page’ => 5)); while ($some_featured_posts->have_posts()): $some_featured_posts->the_post(); $count++; if( $count <= 2 ) the_post_thumbnail( ‘large’ ); elseif( 3 == $count ) the_post_thumbnail( ‘medium’ ); else the_post_thumbnail( ‘thumbnail’ ); endwhile; wp_reset_postdata(); ?>