get_post_thumbnail_id returns a negative number

Try this code: <?php $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,’full’, true); if ( !empty($thumb_url[0])) { echo “There is a thumbnail and it’s id is: “.$thumb_id; } else { echo ‘There is no picture.’; } ?> For the second code, use: <?php $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,’full’, true); if ( !empty($thumb_url[0]) ) : ?> <img … Read more

Set featured image on creating new post

Ok, it’s my fault. I’ve installed a “blank”-theme to have a blank frontend (because I only use the API) – but I didn’t realize that a theme changes something in the Admin Frontend. By adding this to the functions.php I re-enabled the box: add_theme_support(‘post-thumbnails’);

Edit box-header on WordPress Dashboard

I clearly didn’t know how to google, as this page already explains how to do exactly what I wanted. Adapting it a bit, for it to work with different post types, I came up with the following: add_action(‘do_meta_boxes’, ‘replace_featured_image_box’); function replace_featured_image_box() { $post_types = array(‘bwps’, ‘page’, ‘post’); foreach( $post_types as $post_type ) { remove_meta_box( ‘postimagediv’, … Read more