寻求WordPress经典文章页的Telegram社交分享按钮链接
实现WordPress经典编辑器页面的Telegram分享按钮
直接给你和现有Facebook按钮结构完全一致的Telegram分享按钮代码,替换后即可使用:
<a href="https://t.me/share/url?url=" class="social-share-button social-share-button-tg" title="分享到Telegram" target="_blank" rel="nofollow noopener noreferrer" aria-label="分享到Telegram" onclick="window.open('https://t.me/share/url?url=' + encodeURIComponent(document.URL) + '&text=' + encodeURIComponent(document.title)); return false;"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"> <path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm165.2 169.9l-170.3 71.5c-15.3 6.4-32.4-2.7-32.4-18.3V112.1c0-15.7 17.1-24.8 32.4-18.3l170.3 71.5c15.3 6.4 15.3 30.4 0 36.8z"/> </svg> </a>
关键细节说明:
- Telegram官方分享链接格式为
https://t.me/share/url?url=[分享地址]&text=[分享文本],url为必填参数,text可选(示例中用document.title获取文章标题,也可换成document.URL和你的Facebook按钮逻辑完全对齐) - 类名
social-share-button-tg用于和现有按钮样式统一,可根据你的CSS规则调整 - 内嵌SVG是Telegram官方图标,无需外部资源依赖
onclick逻辑和Facebook按钮完全一致:通过encodeURIComponent处理URL避免编码错误,用弹窗打开分享页面,return false阻止默认跳转行为
内容的提问来源于stack exchange,提问作者Kambro
相关产品推荐
相关产品推荐

