douboshan1466 2019-01-28 18:14
浏览 29

翻译wordpress中的文本

I'm using WPML plugin to make my website multilingual and some of the text / button text can't be translate.

I have this code:

<div class="header-left">
    <div class="num">
        <strong>  Call us Now </strong>
        <a href="tel:0000000"> +000000 </a>
    </div>
</div>

I have this block of code in wordpress php file.

How to add this as a string so i can translate it with WPML?

  • 写回答

1条回答 默认 最新

  • download12749 2019-01-28 18:20
    关注

    You have to put the text in a function like this :

    <?php echo __('Call us Now', 'yourtextdomain'; ?>
    

    or you can just do

    <?php _e('Call us Now', 'yourtextdomain'; ?>
    

    Then go to WPML and resync your theme or plugin where you have this text. (There is also an option to do that automatically)

    Check the doc to know more :

    https://developer.wordpress.org/reference/functions/__/

    评论

报告相同问题?