← WordPress

Miniaturas Wordpress

Lida 1237 vezes

Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Viva +t,
Tenho este código para mostrar as miniaturas de cada artigo no tema:
Código: (php) [Seleccione]
<?php 
if ( has_post_thumbnail() ) {
the_post_thumbnail(array(210,280));

?>

O problema éque quero que as imagens fiquem exactamente neste tamanho, mas nunca ficam. Como é possílve fazê-lo?
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

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

Viva +t,
Tenho este código para mostrar as miniaturas de cada artigo no tema:
Código: (php) [Seleccione]
<?php 
if ( has_post_thumbnail() ) {
the_post_thumbnail(array(210,280));

?>

O problema éque quero que as imagens fiquem exactamente neste tamanho, mas nunca ficam. Como é possílve fazê-lo?

Experimenta adicionar isto no functions.php:
Código: [Seleccione]
add_image_size( 'category-thumb', 210, 9999 );
O 240 é a largura. A altura é automaticamente definida.
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Pois, isso eu já sabia. Mas e se eu quiser mesmo ter um quadrado de 150x150 ou assim?
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

Crias varias miniaturas no functions.php.
Código: (php) [Seleccione]
/** Miniaturas */
if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 150, 150, true );
    add_image_size( 'mini', 100, 100, true );
    add_image_size( 'featured', 315, 118, true );
}
/** END Miniaturas */

Depois para as chamar, usas:

Código: (php) [Seleccione]
<?php
   
if ( has_post_thumbnail() )
      
the_post_thumbnail('mini'); //escolhes o nome da miniatura, que definiste no functions.php
   
else
      echo 
'<img src="http://site.com/images/semthumbnail.jpg" alt="" title="" />';
 
?>

E tens de reenviar as imagens todas para serem criadas de novo as miniaturas todas. (Existem plugins que fazem isto automaticamente.)