WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Are you using any plugins on your site? – Joshua Abenazer Aug 28 '12 at 13:27
@josuha yes, that particular custom is inside a plugin itself – krike Aug 28 '12 at 17:56

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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