首页 文章

如何在qoutes中获取wordpress发布作者电子邮件

提问于
浏览
2

我想在single.php页面上的“myeamil@live.com”中引用wordpress发表作者电子邮件 .

其实我想发邮件给发布这篇文章的那位作者 .

我正在使用wp_mail函数从single.php页面向作者发送电子邮件 .

这是我正在使用的变量,但它正在收到管理员电子邮件 .

$emailTo = get_option('admin_email');

而不是管理员电子邮件,我想要发布帖子的作者电子邮件 . 我需要帮助 . 非常感谢 .

Update

这是我想要做的代码

if(!isset($ hasError)){// $ emailTo =“w_chand@live.com”; if(!isset($ emailTo)||($ emailTo =='')){$ emailTo = the_author_meta('user_email'); } $ subject ='电子邮件主题在这里' . $ name; $ body =“名称:$ Name nnDuration:$ duration nnComments:$ comments”; $ headers =“回复:'” . $ name . “'rn”; if(wp_mail($ emailTo,$ subject,$ body,$ headers)){echo“查询已成功发送”; } else {echo“邮件功能错误!”; }

3 回答

  • 1

    您可以通过 get_the_author_meta() wordpress函数获取作者电子邮件地址 .

    <?php 
          $user_email = get_the_author_meta('user_email');
    ?>
    

    获取用户ID 25的电子邮件地址,并使用其显示名称作为锚文本进行回显 .

    <p>Email the author: 
         <a href="mailto: 
              <?php echo get_the_author_meta('user_email', 25); ?>"
         >
              <?php the_author_meta('display_name', 25); ?>
         </a>
    </p>
    

    以下功能是 deprecated

    <?php the_author_email(); ?>
    

    将作者电子邮件地址显示为“mailto”链接 .

    <a href="mailto:<?php the_author_email(); ?>">Contact the author</a>
    

    演示代码

    <div id="about-author-wrap">
         <div class="about-author-avatar">
            <?php echo get_avatar( get_the_author_email(), '90' ); ?>
         </div>
         <div class="about-author-info">                                
            <h5>About the Post Writer <small>View all posts by <?php the_author_posts_link(); ?></small></h5>
        </div>
        <div class="about-author-description">
            <?php the_author_meta("description"); ?>
        </div>
    </div>
    

    希望这对你有所帮助!

  • 0

    试试下面的代码 . Reference page . 希望能帮助到你 .

    <?php $user_email = get_the_author_meta('user_email'); ?>
    
  • 0

    尝试:

    $emailTo = '"'.the_author_meta('user_email').'"';
    

相关问题