【问题标题】:How to change the currency symbol position in wordpress?如何更改 wordpress 中的货币符号位置?
【发布时间】:2014-02-22 22:30:10
【问题描述】:

我正在开发一个免费的 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 } ?>

感谢您的帮助。

【问题讨论】:

    标签: php wordpress currency custom-post-type


    【解决方案1】:

    答案是改变回声的顺序:

    <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 } ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 2013-07-03
      • 2012-09-04
      相关资源
      最近更新 更多