[英]How to get WordPress blog name in custom emails
I use wp_mail to send out custom emails.我使用 wp_mail 发送自定义电子邮件。 All works great but I can't get the blog name via shortcode within the email body.一切正常,但我无法通过 email 正文中的简码获取博客名称。
Seriously?严重地? Yes... I'm afraid so.是的……恐怕是这样。
I have tried:我试过了:
function yl_blog_name_shortcode() {
return get_bloginfo('name');
}
add_shortcode('yl_blog_name','yl_blog_name_shortcode');
function yl_blog_name_shortcode() {
return get_option('blogname');
}
add_shortcode('yl_blog_name','yl_blog_name_shortcode');
But nothing...但是什么都没有...
You would say this is a way too easy question right?你会说这个问题太简单了吧? Well, every time I only get the actual [yl_blog_name] shortcode as text in stead of the BLOG NAME.嗯,每次我只得到实际的 [yl_blog_name] 短代码作为文本而不是 BLOG NAME。
I think I need to add a global or something?我想我需要添加一个全局的还是什么?
Thanks.谢谢。
Try to use do_shortcode() function. You should use [shortcode] only in text editors or text widgets of Wordpress, but not in any code.尝试使用 do_shortcode() function。您应该只在 Wordpress 的文本编辑器或文本小部件中使用 [shortcode],而不是在任何代码中。 If you want to use shortcode in PHP code, you should use do_shortcode() function.如果你想在 PHP 代码中使用短代码,你应该使用 do_shortcode() function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.