Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Copa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Cómo añadir miniaturas de entradas en WordPress

Nota editorial: Ganamos una comisión de los enlaces de socios en WPBeginner. Las comisiones no afectan a las opiniones o evaluaciones de nuestros editores. Más información sobre Proceso editorial.

Las miniaturas de entradas son cada vez más populares. Muchos temas de revistas asocian una imagen a una entrada específica que luego muestran en la página de inicio o en la página de entradas. Nosotros mostramos una miniatura con nuestras entradas tanto en la página de entradas como en la página de categorías. En versiones anteriores, esta funcionalidad se obtenía con el uso del método de campo personalizado que no era muy fácil de usar. Gracias a los desarrolladores del núcleo de WordPress junto con muchas características notables en WordPress 2.9, esta función también fue añadida al núcleo.

Simplemente vea el video o lea el tutorial a continuación :)

Vídeo

Guía para principiantes

Verás una opción como esta en la barra lateral de tu Panel de Escribir Entradas en el Escritorio de WordPress.

Post Thumbnails in WordPress

Haz clic en el enlace, y serás llevado a una página de subida de imágenes. Sube la imagen, y verás algo como esto:

Post Thumbnails in WordPress

Enlaza el enlace que dice Usar como miniatura. Una vez hecho esto, verás una pantalla como esta:

Post Thumbnails in WordPress

La pantalla de arriba significa que has terminado. Simplemente haga clic en publicar y la imagen se mostrará en su sitio.

Guía del desarrollador

Aunque esta funcionalidad está añadida al núcleo, no todos los usuarios verán esta opción en la barra lateral de su panel de entradas de escritura. Esta es una de esas funciones que pueden ser activadas solo si el tema es compatible con ella. Los temas gratuitos más antiguos pueden no ser compatibles con ella, por lo que tendrás que pedir al desarrollador que la actualice, o puedes hacerlo tú mismo siguiendo este tutorial.

Primero tendrás que abrir tu archivo functions. php en la carpeta de temas y pegar el siguiente código:

add_theme_support( 'post-thumbnails' );

Este código activará el tema es compatible con ambas entradas y páginas. Así que ahora usted será capaz de ver una opción en su tablero de instrumentos. Pero no se mostrará en sus temas porque no hemos añadido el código en el tema todavía.

Puede mostrar la miniatura en cualquier lugar dentro del Bucle mediante el uso de este código:

<?php the_post_thumbnail(); ?>

Esa es la función básica, pero si quieres ir más allá, como especificar el tamaño de la miniatura de la entrada, sólo tienes que abrir tu archivo functions.php y pegar el código como este:

add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 50, 50, true );

Las dimensiones se establecen en este orden: ancho x alto y estos son píxeles.

También puede añadir tamaños de imagen adicionales para su imagen destacada añadiendo esta línea:

add_image_size( 'single-post-thumbnail', 590, 180 ); // Permalink thumbnail size

Más tarde puede llamar a los tamaños específicos de miniaturas en su bucle de entradas de esta manera:

<?php the_post_thumbnail('single-post-thumbnail'); ?>

Esta es una versión desglosada de la funcionalidad completa de esta característica. Tratamos de mantenerlo simple, para que todos puedan seguirlo. Si desea obtener más información sobre esta funcionalidad, a continuación, marcar / comprobar:

Artículo de Mark Jaquith sobre miniaturas de entradas
Códice de WordPress

Descargo: Nuestro contenido está apoyado por los lectores. Esto significa que si hace clic en algunos de nuestros enlaces, podemos ganar una comisión. Vea cómo se financia WPBeginner , por qué es importante, y cómo puede apoyarnos. Aquí está nuestro proceso editorial .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

El último kit de herramientas de WordPress

Obtenga acceso GRATUITO a nuestro kit de herramientas - una colección de productos y recursos relacionados con WordPress que todo profesional debería tener!

Reader Interactions

80 comentariosDeja una respuesta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Chrissy says

    Is this necessary with Genesis Child Themes. They seem to have a featured image for their posts already. Thanks

  3. Kathleen Smitheram says

    So… I tried this and I think I broke my site. I now get this error

    Parse error: syntax error, unexpected ‘”‘ in /home/content/21/10729521/html/wp-content/themes/desk-mess-mirrored/functions.php on line 642

    and can’t get into my dashboard. I’m new to self-hosting and I have no idea how to fix this. HELP!

  4. Drew says

    Hi,

    Thanks for this post it totally helped me out!

    Question, now how would I also show the featured image (in a different size) within the actual post only (not in the loop)?

    Thanks :)

  5. canada goose jackets says

    Keep writing, continue to inspire, to keep creating I like the idea and the website is fairly easy to use. I do wish that they would review more than the top 20 or so websites in the field. The web is a big place.

  6. canada goose jackets says

    Keep writing, continue to inspire, to keep creating I like the idea and the website is fairly easy to use. I do wish that they would review more than the top 20 or so websites in the field. The web is a big place.

  7. mbtshoesmbts says

    Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can’t wait to read lots of your posts.

  8. lakkolmahendra says

    Thank you very much for the wonderful information. It’s simple method to add thumnail in your homepage. I’ll try for my site today.

  9. LukeSwenson says

    I’m working on WorPress Version 3.2.1. I noticed that the module in the admin reads “Featured Image” rather than “Post Thumbnail.”

    Also, I get the following error when I try to add an image in the admin:

    Warning: Cannot modify header information – headers already sent by (output started at /——–/—-/——/——-/wp-content/themes/html5/functions.php:58) in /Applications/MAMP/htdocs/justine/wp-admin/async-upload.php on line 2648

  10. SagivHaalush says

    @wpbeginner Hey :) VERY(!) helpful post, However I got to the exact same problem after adding the 2 lines(at the bottom…). When I put them at the beginning, nothing happens…

    Can you please be more specific as for the placement in the loop(Which/where)? Thanks :)

  11. birdhammer says

    Hi there, I just tried to enter the code above by following instructions in the video, but when I updated it I got a parse error. I cannot even log into my dashboard. I feel like an idiot!

    I use wordpress with modularity lite theme and my site is birdhammer.com.

    Can you please help me?

  12. wpbeginner says

    The placement of the code in your functions.php file is probably causing the errors. Are you using a theme framework? Are you adding it way at the bottom??

  13. CaseyDennison says

    mines not working at all i keep gettin errors in the php and it is written up correctly. i dunno is screwed it keeps showing the functions code at the very top of my wp dashboard ??? thats weired

  14. davede says

    @wpbeginner Ah thanks, I resolved the problem. details here: (well seems i can’t paste a url in). that sucks.

  15. davede says

    Good stuff.Thank you.

    I’m having a hard time having the thumbnail appear only in the excerpt not on the post page.

    any ideas?

  16. kevin.m.kwok says

    Hello, great tutorial. Everything works, except I can’t get the thumbnail to post “left” of my post on my homepage. It always goes on top of my post, even if I select left in the thumbnail options. Any Ideas?

  17. Peter Wolff says

    Hi WP Beginner.

    Great WP tutorial above from the Editorial Staff!

    I have a quick WP thunmbnail gallery page photo question. I’ve been trying to add some simple Custom Field php code to my Catefory.php template in order to add a small text caption title below each thumnail image. Very frustrated…anyway, I have attached below the Category.php thumbnail loop and was wondering if you can help me write the a Custom Field php code (field called “thumb_tag”) within this loop. Here’s the code:

    ID, ‘main_image’, true); ?>

    <a href="” ><img src="/resize.php?w=162&h=105&file=” alt=”” title=”” width=’162′ height=’105′ />

    Thank you very much!

    Pete

  18. shivam says

    i am new to wordpress,not knowing too much programming..i liked ur article.but can u tell me exact at which position we have to place this code..like fuctions.php is a file,which we have to edit,at what place we have to add that code,is there any demo for that?

  19. mark says

    Great tutorial – However, and I cant find this information anywhere – BUT, I want to add the thumbnail to the post-editor screen so that my writers can see what it would look like inline with the post before they publish. Where could I do that? Thanks in advance.

    • Editorial Staff says

      You see the thumbnail once you upload it, however there is no live preview on the admin screen. Your author can simply click Preview and see the post in the new tab <<

      Administrador

  20. elizabeth says

    Hi
    Thank you for the info. i followed the steps in my theme, however my pictures still do not show in the image box…they look like broken files on my Home page. When I click on them, then they appear. How can i make them visible on the home page? Thanks

  21. janine says

    Thanks for the great post – specifically about add_theme_support( ‘post-thumbnails’ ); – It worked great with the wootheme I am modifying

  22. saBEE says

    Thank you for the great information.

    Each of my posts has a photo. I am trying to get each post’s photo to show up as a thumbnail in the RSS feed. Will the above method work to do this?

  23. Bernard says

    I’ve gone through the steps in this tut, but for some reason I get the following error whenever I try to select an image from the gallery option:

    Fatal error: Call to undefined function: get_post_thumbnail_id() in /wp-admin/includes/media.php on line 1292

    Can anyone help me in sorting this out?

    thanks
    Bernard

  24. darren says

    is this actually cropping the image on upload? Or does it just display it at the appropriate height and width when it calls it on the page? I ask b/c we pull our feed from our blog onto a non wp site and link back to it but would like to be able to reference the thumbnails. It is a asp site so I don’t have the luxury of php’s native image manipulation

  25. Helen says

    Hello
    We have this code in theme functions (it came with theme skin) the theme has a image slider that uses the ‘post thumbnail’ function. yet it doest show in admin so we cant get slider to work;

    <?php

    help : ) thank you

  26. Ami says

    works great!! just one query.. how can i add a link or wrap a link around

    so that when someone click the link a lightbox opens with the original size.

    Just to clarify.

    At the moment in functions.php I have

    add_image_size(‘my-custom-image’, 640,9999); so the image in the post is 640 in width, this will then be linked to the original image which is say 1000px by 500px.

    I did find this: http://polymathworkshop.com/shoptalk/2010/03/19/get-the_post_thumbnail-direct-path-for-wordpress/ which works to a degree but opens the thumbnail in the lightbox.

  27. Eduardo Antunes says

    Cool!

    To remember:

    > add in functions.php

    add_theme_support(‘post-thumbnails’);
    set_post_thumbnail_size(70, 70, true);

    > add in the loop:

    php the_post_thumbnail();

  28. Ricky@twitter apps says

    Weel I was looking for the same thing. I have a quick question for ya. Is there any way to have default image of the category to show as a thumbnails? Or is there anyway to fetch first image of the post and use it as thumbnail as related post.
    I implemented the above technique on my blog but the major problem is my all the posts doesn’t have thumbnail enabled. Which makes the situation horrible as I have to update all the post with thumbnail.
    Is there anyway to use first image as default thumbnail using above technique?

  29. Jal says

    Editors,

    Do you use the wordpress’s post editor or some offline blog publishing software? I use Live Writer which has some decent options but sometimes I think of a switch-over to Wp’s post editor. Can you share some views on this please?

    Thank you

  30. Antonio says

    Wow thanks I’ve always wondered how to do this but never really had the patience to look for a solution. I didn’t know it was this simple. WOOOOT! Thanks. :)

  31. Trisha says

    Any idea if this works for Page thumbnails? I’m trying to list child pages using this code. (the 2nd one, in ‘post format’. Switched out all instances of ‘content’ with ‘excerpt’ and used Andrew Oz’s Excerpt Editor which is seriously cool.

    When I try to plug in the code for the thumbnail, it doesnt show.

    Any idea what I might be doing wrong?

  32. Cosmin says

    Guys, does this only work with square images?

    As in 50px by 50px?

    I heard someone mention it only takes the height value when specifying dimensions…
    (so 50px by 30px wouldn’t work)

    • Editorial Staff says

      It will work with any size. Sometimes the image quality will be lost if it is not the right ratio. We have it working on a client’s website and it works perfectly fine.

      Administrador

  33. Luke says

    I’m a beginner and love what you’re doing. Would be nice to get very specific instructions for stuff like this. When I copy/paste to functions it doesn’t work.

    Thoughts on what I could be doing wrong? Maybe a functions for beginners post?

    Thank you and keep up the great work.

    • Editorial Staff says

      Are you using WordPress 2.9? If so then there is no way that it would not work. This is probably the best break down of this code.

      While we try to make everything as clear as possible, sometimes it requires prior knowledge to complete some tasks.

      If you want one of our staff to take a look and do this for you we can do it for a small fee.

      Administrador

  34. Cosmin says

    Sweeeeeet!

    Thanks guys, perfect timing, as I’m working on a WordPress theme for a client and it requires just this!

    Now it will be sooo easy for the less-tech-savvy person that’ll write posts :)

Deja tu comentario

Gracias por elegir dejar un comentario. Tenga en cuenta que todos los comentarios son moderados de acuerdo con nuestros política de comentarios, y su dirección de correo electrónico NO será publicada. Por favor, NO utilice palabras clave en el campo de nombre. Tengamos una conversación personal y significativa.