← WordPress

Mostrar valor só quando têm

Lida 2230 vezes

Offline

Riey 
Membro
Mensagens 1001 Gostos 0
Feedback +4

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


Boas,
utilizo o seguinte código para apanhar o valor colocar num "Custom Field":

Código: [Seleccione]
<?php $key="imagem"; echo get_post_meta($post->ID$keytrue); ?>
Mas gostava de mostrar este valor apenas se fosse colocado no Custom Field do artigo... Aliás, gostava que uma certa área só aparece se colocasse um valor em certo campo...

Alguém me pode ajudar? Obrigado...
Offline

STronic 
Elite
Mensagens 546 Gostos 8
Feedback +5

Troféus totais: 30
Trófeus: (Ver todos)
Mobile User Search Apple User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Código: [Seleccione]
<?php if (get_post_meta($post->ID'imagem''true') <> '' ) { ?>
<?php echo get_post_meta($post->ID'imagem'true); ?>
<?php ?>
Offline

Riey 
Membro
Mensagens 1001 Gostos 0
Feedback +4

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

Código: [Seleccione]
<?php if (get_post_meta($post->ID'imagem''true') <> '' ) { ?>
<?php echo get_post_meta($post->ID'imagem'true); ?>
<?php ?>


Obrigado. Vou experimentar.
Offline

Riey 
Membro
Mensagens 1001 Gostos 0
Feedback +4

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

Funcionou às maravilhas :D

Muito obrigado!

(desculpa a demora mas só agora voltei a mexer no código...)