I created a new custom post type based on the code provided by the wordpress codex. But when I try to set a featured image it returns and shows -1 in the featured image box instead of the images.

I checked in the function that sets the featured image and it looks like it doesn't pass the check to see if I'm allowed to edit the post ( current_user_can('edit_post', $postID) )

However when I check somewhere in my plugin (I'm adding meta boxes in that particular page) with the same function it shows that I have the right to edit the page.

Anyone an idea why it is causing a problem with the featured image?

  • Are you using any plugins on your site? Commented Aug 28, 2012 at 13:27
  • @josuha yes, that particular custom is inside a plugin itself
    – Christophe
    Commented Aug 28, 2012 at 17:56

1 Answer 1


I would start by checking that everything is good with the image being saved to the CPT. Inside the loop...

<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<?php echo $url ?>

This will hopefully echo the image's URL... if that is working then you probably have a problem with the loop conflicting with something else on the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.