質問

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