[英]2 pieces of similar PHP, one works one doesn't?
I've got a few fields on a property site, grabbing a value in English & depending on the value, translating it (if another language other than English is selected). 我在房地产网站上有几个字段,使用英语获取值,然后根据该值进行翻译(如果选择了英语以外的其他语言)。
This piece of code works fine: 这段代码可以正常工作:
<?php if(get_post_meta($post->ID,'prop_parking',true) && $prop_parking):
$prop_parking_meta = get_post_meta($post->ID,'prop_parking',true);
if ($prop_parking_meta == 'Yes') {
$prop_parking_meta = '<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->';
}
elseif ($prop_parking_meta == 'No') {
$prop_parking_meta = '<!--:en-->No<!--:--><!--:es-->No<!--:--><!--:ru-->нет<!--:-->';
} ?>
<li>
<p><?php echo PROP_PARK_CSTM;?>:</p><p> <?php _e( $prop_parking_meta ); ?></p>
</li>
<?php endif; ?>
I get back Yes
in the set language, yet in this field I don't (I just see Yes
or No
): 我以设定的语言返回“
Yes
”,但是在该字段中我没有(我只是看到“ Yes
或“ No
):
<?php if(get_post_meta($post->ID,'prop_garage',true) && $prop_garage):
$prop_garage_meta = get_post_meta($post->ID,'prop_garage',true);
if ($prop_garage_meta == 'Yes') {
$prop_garage_meta = '<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->';
}
elseif ($prop_garage_meta == 'No') {
$prop_garage_meta = '<!--:en-->No<!--:--><!--:es-->No<!--:--><!--:ru-->нет<!--:-->';
} ?>
<li>
<p><?php echo PROP_GARG_CSTM;?>:</p><p> <?php _e( $prop_garage_meta ); ?></p>
</li>
<?php endif; ?>
Is it something obvious I'm missing? 我想念的东西很明显吗? :( Thanks!
:( 谢谢!
I don't know why this issue happens sometimes in qTranslate, but there are two options to deal with it: 我不知道为什么有时在qTranslate中会发生此问题,但是有两个选项可以解决:
using the shortcode notation 使用简码表示法
$prop_garage_meta = '[:en]Yes[:es]Sí[:ru]да';
applying the_content
filter 应用
the_content
过滤器
$prop_garage_meta = apply_filters( 'the_content', '<!--:en-->Yes<!--:--><!--:es-->Sí<!--:--><!--:ru-->да<!--:-->' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.