php - “通过电子邮件发送此页面”链接到 WordPress/WooCommerce 存档页面不会获取页面 URL
问题描述
尝试向 WordPress/WooCommerce 中的存档页面添加“通过电子邮件发送此页面”链接。它在侧边栏中(所以在循环之外)
我希望最终得到的代码是
<a href=mailto:?subject="(page_title)"&body="Some text (url_to_the_page_being_viewed)">通过电子邮件发送此页面
我已经尝试了很多东西,例如
<?php
echo '<a href="mailto:?subject=' . the_title() . '&body=' . the_title() . ' - ' . echo get_permalink( get_queried_object_id() ) . '">E-Mail This Page</a>' ;
?>
但目前还没有快乐。
我错过了什么?
解决方案
用这个:
global $wp_query;
$catName = $wp_query->query_vars['product_cat'];
$link = home_url().'/product-category/'.$catName;
$title = get_the_title();
echo "<a href='mailto:$link?subject=$title&body=$title'>E-Mail This Page</a>";
推荐阅读
- google-admin-sdk - 从 Web 应用程序执行用户模拟
- r - R的ggplot2中geom_point中数据点的垂直线
- python - 有多少受访者表示他们只使用“MySQL”?
- php - 在 php 站点上 SELECT 后更新数据库
- objective-c - 试图让 NSUserNotifications 在我的应用程序中工作
- delphi - 在两台机器上运行相同的 Delphi 应用程序,一台立即返回“Resource TfrmHSMain not found”,另一台运行正常
- android - 如何确定如何使用 APK 依赖项?
- python - pywinauto,不识别子窗口
- r - 闪亮的应用程序在本地加载时间与部署在远程服务器上时
- python - 如何从 ListView 获取 pk 值并使用它?