Specific featured image for each category

<?php if(has_post_thumbnail()) the_post_thumbnail(‘themolio-featured-image’); else echo wp_get_attachment_image($attachment_id, ‘themolio-featured-image’); ?> The above code displays the featured image if the post has one, otherwise the image define by $attachment_id. I don’t know how you’re deciding which category term should display which image & what to do in case of multiple categories, so the part where you initialize $attachment_id … Read more

Change wording of default thumbnail metabox

This is usually what I go with: /** Use “Featured Image” Box As A Custom Box **/ function customposttype_image_box() { remove_meta_box(‘postimagediv’, ‘page’, ‘side’); add_meta_box(‘postimagediv’, __(‘Set Dat Image’), ‘post_thumbnail_meta_box’, ‘page’, ‘side’); } add_action(‘do_meta_boxes’, ‘customposttype_image_box’); /** Change “Featured Image” box Link Text **/ function custom_admin_post_thumbnail_html( $content ) { global $post; if($post->post_type == ‘page’) { $content = str_replace( … Read more

Change Output for Images in Content

One way is to do this dynamically: function do_the_replacements($matches){ // $matches[0] = full string // $matches[1] = link attributes // $matches[2] = link contentes (the image) // change ‘someclass’ here… if(strpos($matches[2], ‘someclass’) !== false){ return ‘ <div class=”featured-img”> <a ‘.$matches[1].’>’.$matches[2].'</a> <div class=”corner-nw”></div> <div class=”corner-ne”></div> <div class=”corner-sw”></div> <div class=”corner-se”></div> </div> ‘; } // no matches, leave … Read more

How to get_posts having post thumbnail?

The thumbnail is stored as a meta with a key of _thumbnail_id, so that could be used to find posts that have thumbnails. Something like this: $query = new WP_Query(array( ‘meta_query’ => array( array( ‘key’ => ‘_thumbnail_id’, ‘value’ => ‘0’, ‘compare’ => ‘>=’, ) ) ));

can the_excerpt function also get images?

Ensure that your Theme supports Post Thumbnails, and that the client sets a “Featured Image” for each post. Then, combine the_excerpt() with the_post_thumbnail(), e.g. like so: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <div class=”featured-image”><?php the_post_thumbnail(); ?></div> <div class=”post-excerpt”><?php the_excerpt(); ?></div> </div> … Read more