← WordPress

Adicionar thumbnails

Lida 2196 vezes

Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Boa Noite,

Já tentei isto: http://codex.wordpress.org/Function_Reference/the_post_thumbnail

Mas não estou a conseguir adicionar um thumbnail

index.php

Código: (php) [Seleccione]
<div class="box post" id="post-<?php the_ID(); ?>">
<div class="content">
<?php $postimageurl get_post_meta($post->ID'post-img'true); if ($postimageurl) { ?>
                    <div class="pic fl">
                      <?php the_post_thumbnail(); ?>
                    </div>
<?php ?>
<div class="post-title">
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<!--/post-title -->
<div class="post-date"><em>On <?php the_time('m.d.y'); ?>, In <?php the_category(', '?>, by <?php the_author_posts_link(); ?></em></div>
<div class="post-excerpt"><?php the_excerpt(); ?></div>
<!--/post-excerpt -->
</div>
<!--/content -->
<div class="hl"></div>
<div class="social-links">
<div class="fl">
<span><?php comments_number(01'%'); ?></span>
<a href="<?php the_permalink(); ?>#comments" title="View Comments">Comments</a>
</div>
<div class="fr"><span><a href="<?php the_permalink(); ?>#respond" title="Leave Your Response">Leave Your Response</a></span></div>
<br class="fix" />
</div>
<!--/social-links -->
</div>
<!--/box -->


Alguém pode indicar-me porque é que o thumbnail não é adicionado?

NOTA: Já adicionei add_theme_support( 'post-thumbnails' ); no functions.php e já seleccionei a imagem de destaque no painel de administração...


Desde já muito obrigado.
Offline

Nuno 
Administrador
Mensagens 7780 Gostos 216
Feedback +2

Troféus totais: 42
Trófeus: (Ver todos)
100 Poll Votes Level 7 Search Mobile User Level 6 Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes

Vamos por partes, quando colocas o código no functions.php o menu/caixa de selecção do thumbnail aparece nos posts?

Tens este excelente artigo do Hugo Baeta no wordpress pt a explicar como se faz isso.
http://wp-portugal.com/2010/02/20/miniatura-thumbnail-do-post-como-implementar/
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Vamos por partes, quando colocas o código no functions.php o menu/caixa de selecção do thumbnail aparece nos posts?

Sim, aparece.

Tens este excelente artigo do Hugo Baeta no wordpress pt a explicar como se faz isso.
http://wp-portugal.com/2010/02/20/miniatura-thumbnail-do-post-como-implementar/

Testei tudo o que ai dizia... mas sem sucesso. :(
Offline

João Pacheco 
Membro
Mensagens 226 Gostos 0
Troféus totais: 23
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 4 Level 3 Level 2 Level 1 100 Posts 50 Posts

Tens aqui um post elaborado pelo Nuno que coloca thumbnails automáticos (não sei se já tentas-te):

http://www.maistrafego.pt/wordpress-thumbnails-automaticos-custom-fields-plugins
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Tenta: the_post_thumbnail('thumbnail');

Duvido que seja isso, mas tenta...
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Tenta: the_post_thumbnail('thumbnail');

Duvido que seja isso, mas tenta...

Não funciona.



Eu apenas...

Adicionei ao functions.php:

Código: [Seleccione]
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 50, 50, true );
add_image_size( 'single-post-thumbnail', 400, 9999 );

depois no index.php:

Código: [Seleccione]
<?php the_post_thumbnail(); ?>

Falta alguma coisa?
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Uso assim em todos os meus projectos e funciona na perfeição.

Código: (php) [Seleccione]
/** Miniaturas */
if (function_exists('add_theme_support')) {
   add_theme_support( 'post-thumbnails' );
   set_post_thumbnail_size(150, 150, true);
}
/** END Miniaturas */

Código: (php) [Seleccione]
<?php
if ( has_post_thumbnail() )
   
the_post_thumbnail('thumbnail');
else
   echo 
'<img src="http://libertytuga.com/wp-content/themes/libertytugav4/images/nothumbnail.jpg" alt="" title="" />';
?>


http://www.wptotal.com/2010/como-adicionar-miniaturas-thumbnails-blog
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Não funciona.. :|
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Estranho... lol
Estas a adicionar bem a miniatura ao post?

Vê o post no link que deixei como o fazer.