-1

Like title said. I need delete blank space when post_meta don't have value.

Code example:

<?php
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'direccion', true);
if($meta != $empty) { echo "".$meta.""; }
?>

Entire code:

<?php
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'direccion', true);
if(!empty($meta)) {
echo $meta;
}
?>

<?php global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'provinciadestacada', true);

if(!empty($meta)) {
    echo $meta;
}

elseif(in_category( '951' )) {
    echo 'Todas las provincias';
 } ?> 

<?php global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'poblacion', true);
?>

<?php global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'codigopostal', true);
if($meta != $empty) { echo "(".$meta.")"; }
?>
4
  • Sorry, but what do you want to do with this? What is $empty? And what does delete blank space mean? Apart from that it even doesn't have any value...
    – tfrommen
    Dec 30, 2013 at 21:47
  • When don't have value, or not? I'm new in programming sorry @tf Dec 30, 2013 at 21:49
  • Looks an awful lot like your other question that has already been closed. And you seem to have not payed attention to the advice given in that thread.
    – s_ha_dum
    Dec 30, 2013 at 22:38
  • @s_ha_dum thanks for answer, thanks to your comment i detected value "&nbsp" inside this custom field. Problem solved. Really thanks Dec 30, 2013 at 23:18

1 Answer 1

2

do you want this:

<?php
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, 'direccion', true);
if(!empty($meta)) {
   echo $meta;
}
?>
1
  • This is my first Custom site. Sorry for my ignorance and my bad english. It's too hard talk about programming with proffesionals but i like try it! thanks @Abhishek Dec 30, 2013 at 22:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.