如何更改wordpress中的货币符号位置?

时间:2014-02-22 22:30:11

标签: php wordpress currency custom-post-type

我正在制作一个免费的wordpress分类广告主题,并发现更多的货币符号的想法,但我希望你的价格将在符号之后。例如。 200 $

这里是代码:

<section class="thumb_item">
<?php if (get_post_meta($post->ID, 'price', true) !== '') { ?>
<span class="price"><?php
if(get_option('currency') != ''){
echo get_option('currency');
}else{
echo get_option('currency_symbol');
}
echo get_post_meta($post->ID, 'price', true);
?></span>
<?php } ?>

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

答案是改变回声的顺序:

<section class="thumb_item">
    <?php if (get_post_meta($post->ID, 'price', true) !== '') { ?>
        <span class="price"><?php
        // Moved the following line from the end to here so echos price first
        echo get_post_meta($post->ID, 'price', true);
        // Now echo the currency symbol
        if(get_option('currency') != ''){
            echo get_option('currency');
        }else{
            echo get_option('currency_symbol');
        }
    ?></span>
<?php } ?>
相关问题