在wordpress中,当我们必须打印东西时,我们会使用\\u e。示例-
<div class="col-md-12 col-sm-12 col-xs-12 tuts">
<p><?php _e( \'We are sorry, but there is nothing here! You might even call this a 404 Page Not Found error message, which is exactly what it is. The page you are looking for either does not exist, or the URL you followed or typed to get to it is incorrect in some way.\', \'tuts\'); ?></p>
</div>
其中tuts是一个文本域。上述设置试图在WordPress 404页面上打印内容。但是如果我想插入一个可以导航到主页的链接怎么办。
我想这会管用-“>家
我这样试过-
<?php _e( \'We are sorry, but there is nothing here! You might even call this a 404 Page Not Found error message, which is exactly what it is. The page you are looking for either does not exist, or the URL you followed or typed to get to it is incorrect in some way. Go back to <a href="<?php bloginfo(\'url\');?>">Home Page</a>.\', \'tuts\'); ?>
最合适的回答,由SO网友:Mayeenul Islam 整理而成
你可以这样写:
<?php /* translators: %s: home page URL */
printf( __( \'We are sorry, but there is nothing here! You might even call this a 404 Page Not Found error message, which is exactly what it is. The page you are looking for either does not exist, or the URL you followed or typed to get to it is incorrect in some way. Go back to <a href="%s">Home Page</a>.\', \'tuts\'), get_bloginfo(\'url\') ); ?>
注意,因为我们正在使用
printf(), 这就是为什么我们不使用
_e(), 但我们正在使用
__().
Reference: printf() - PHP