简体   繁体   中英

How to get WordPress blog name in custom emails

I use wp_mail to send out custom emails. All works great but I can't get the blog name via shortcode within the email body.

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.

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. If you want to use shortcode in PHP code, you should use do_shortcode() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM