Adding Thumbnail support to Custom Post Types

miniaturas-wordpressSo you’ve created your Custom Post Type, adding the correct options to activate thumbnails on your type, but the thumbnails metabox does not appear. Why I know those things? Because I just get stuck in the same problem.

Obviously, I have solved it, and when I found magical solutions to rare problems, I come here to share them with you.

Let’s begin. You have created your Custom Post Type, adding this line:

'supports'=>array('thumbnail')

Maybe you have created your custom type with Types or another plugin like that, and you have selected “Thumbnails”. And all of this is useless.

With these four lines in our Theme (funcions.php) or an own Plugin, our problem should dissapear:

function myplugin_thumbnails_support(){
    add_theme_support( 'post-thumbnails', array( 'my-custom-type' ) );
}
add_action('admin_init','miplugin_thumbnails_support');

“Don’t document the problem; fix it”
.- Atli Björgvin Oddsson

¿Te ha gustado el artículo?
1 estrella2 estrellas3 estrellas4 estrellas5 estrellas (2 votos, promedio: 3,00 sobre 5)
Loading...
Artículo escrito por

¡Exprésate! Dejanos tu comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

2 Comentarios

Acuarel

Thanks a lot for this useful tip. I was struggling with this issue!!

onur

This is really helpful, thanks a lot