preg_replace not removed “class”

The hook post_thumbnail_html is just working for featured images aka post thumbnails, hence the name. I’m guessing that’s what you’re missing and where the “problem” originates. But luckily there is another hook for manipulating image tags get_image_tag, there is actually one for just altering the class get_image_tag_class too. Take a look into those. Another hook … Read more

Recommended Media Size for Twenty Fourteen

Twenty Fourteen uses 2 custom media sizes: 672x372px for post thumbnail image size and 1038x576px for ‘twentyfourteen-full-width’ custom image size So for images uploaded after the theme is activated, these 2 size are created automatically, but for images uploaded before twentyfourteen is activated, an available size is used and image is resized via html/css properties. … Read more

Post Image not displaying in category view

add_theme_support( ‘post-thumbnails’ ); only adds the ability to use Featured Images. To have them appear in your site, you’ll need to add code to at least one of your template files, your active theme’s functions.php file, or a custom plugin. // in The Loop if( has_post_thumbnail() ) { the_post_thumbnail(); } // etc. References has_post_thumbnail() the_post_thumbnail() … Read more

Can I use a Custom Field as the Featured Image URL?

Editing the Template The easiest solution would be to use a conditional to display the featured image: if has custom field use it, else use Featured Image You can get the custom field using get_post_meta(), which will return an empty string if the specified key isn’t set: $custom_url = get_post_meta( get_the_ID(), ‘old_featured_image_custom_field’, true ); You … Read more

Admin – no Featured image choice in create new/page|post

Your theme has not registered support for post thumbnails. You need to add one of these as appropriate: add_theme_support( ‘post-thumbnails’ ); add_theme_support( ‘post-thumbnails’, array( ‘post’ ) ); // Posts only add_theme_support( ‘post-thumbnails’, array( ‘page’ ) ); // Pages only add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘movie’ ) ); // Posts and Movies See the Codex (link above) … Read more

Problem with showing featured image

Use an is_single() condition to ensure the thumbnail isn’t added on archive pages. You should also be using get_the_post_thumbnail and prepending it to $content, rather than just echo’ing it out: function put_thumbnail_in_posting( $content ) { if ( is_single() && has_post_thumbnail() && get_post_type() == ‘post’ ) { $thumbnail = get_the_post_thumbnail( null, ”, array( ‘style’ => implode( … Read more

How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?

You can use add_image_size() function to create custom sized images. You only need to paste some piece of codes in your functions.php and then update the template files accordingly. For example : add_image_size( ‘category-thumb’, 300 ); // 300 pixels wide (and unlimited height) add_image_size( ‘homepage-thumb’, 220, 180, true ); // (cropped) And you can use … Read more

Issue on Getting Custom post type Thumbnail’s URL

The href attribute you are passing under the_post_thumbnail() is incorrect. Note that this attribute is applied to the img tag which obviously doesn’t supports href attribute. It would be better to wrap the_post_thumbnail() with an <a> tag. So it will look something like the following: echo ‘<a href=”‘ . get_permalink( $thumbnail->ID ) . ‘”>’ . … Read more