有人能告诉我如何从电子邮件主题中删除网站名称吗。
截至目前,我的电子邮件主题如下:
[sitename] - Subject goes here
我希望它看起来像这样:Subject goes here
我检查了wp_mail()
密码有一个wp_mail
过滤器可用。有人能告诉我如何使用该过滤器来更改我的电子邮件主题吗?
有人能告诉我如何从电子邮件主题中删除网站名称吗。
截至目前,我的电子邮件主题如下:
[sitename] - Subject goes here
我希望它看起来像这样:Subject goes here
我检查了wp_mail()
密码有一个wp_mail
过滤器可用。有人能告诉我如何使用该过滤器来更改我的电子邮件主题吗?
最后,我写了一些代码,效果很好。
我希望这有帮助。
把这个放进你的functions.php
文件
//remove sitename from email subject
add_filter(\'wp_mail\', \'email_subject_remove_sitename\');
function email_subject_remove_sitename($email) {
$blogname = wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES);
$email[\'subject\'] = str_replace("[".$blogname."] - ", "", $email[\'subject\']);
$email[\'subject\'] = str_replace("[".$blogname."]", "", $email[\'subject\']);
return $email;
}
该文件对我不起作用,我必须在wp includes/pluggable中使用它。php
if ( isset( $atts[\'message\'] ) ) {
//$message = $atts[\'message\'];
$blogname = wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES);
$subject = str_replace("[".$blogname."] - ", "", $subject);
$subject = str_replace("[".$blogname."]", "", $subject);
}
我为添加了自定义筛选函数the_posts 在插件中筛选。add_filter(\'the_posts\', \'posts_filter\'); function posts_filter() { … } 这在主循环中运行得很好,这意味着帖子会按照我在posts_filter 作用但我正在打电话get_posts() 在ajax请求中获取一些帖子。在那里,过滤器不起作用。query_posts() 或自定义wp_query 不要工作太多。所以问题是:我如何才能在主循环旁获得按the_p