_e in wordpress + <a href="<?php bloginfo('url');?>">Home</a>

时间:2016-02-16 作者:The WP Intermediate

在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\'); ?>

2 个回复
最合适的回答,由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

SO网友:Devendra Sharma

这是我的密码。您可以使用。

<?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="\'.get_bloginfo(\'url\').\'">Home Page</a>.\', \'tuts\'); ?>