[英]How to get wordpress post author email in qoutes
我試圖在single.php頁面上以諸如“ myeamil@live.com”的報價獲取wordpress帖子作者的電子郵件。
實際上,我想發送電子郵件給發布此帖子的那個作者。
我正在使用wp_mail函數從single.php頁面發送電子郵件給作者。
這是我正在使用的變量,但它正在獲取管理員電子郵件。
$emailTo = get_option('admin_email');
而不是管理員電子郵件,我需要發布該帖子的作者電子郵件。 我需要幫助。 非常感謝。
更新
這是我正在嘗試做的代碼
if(!isset($ hasError)){// $ emailTo =“ w_chand@live.com”; if(!isset($ emailTo)||($ emailTo =='')){$ emailTo = the_author_meta('user_email'); } $ subject ='電子郵件主題到這里'。 $ body =“名稱:$ Name nnDuration:$ duration nnComments:$ comments”;
$ headers =“ Reply-To:'”。$ name。“'rn”; if(wp_mail($ emailTo,$ subject,$ body,$ headers)){
回顯“查詢已成功發送”; } else {echo“郵件功能錯誤!”; }
您可以通過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>
不推薦使用以下功能,
<?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>
希望這對您有所幫助!
嘗試下面的代碼。 參考頁 。 希望能幫助到你。
<?php $user_email = get_the_author_meta('user_email'); ?>
嘗試:
$emailTo = '"'.the_author_meta('user_email').'"';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.