I am working on a free wordpress classifieds theme and found more currency symbol idea, but I wish you the price would be after the symbol. eg. 200 $

Here the code:

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

Thank you for your help.

有帮助吗?

解决方案

The answer is to change the order of the echo:

<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 } ?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top