正如标题所说。当post\\u meta没有值时,我需要删除空格。
代码示例:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$meta = get_post_meta($postid, \'direccion\', true);
if($meta != $empty) { echo "".$meta.""; }
?>
完整代码:
<?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.")"; }
?>
最合适的回答,由SO网友:abhishekfdd 整理而成
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;
}
?>