我编码社交分享按钮,我想将single.php模板中的当前帖子链接到社交媒体共享链接.
我附加固定链接以共享网址时的问题,它不会提供帖子的完整网址:
我试过http://twitter.com/share?url=<?php the_permalink() ?>,但只给了的输出/post/69不是http://example.com/post/69.
任何建议?
Raj*_*ood 10
在post循环之外,你可以使用wordpress get_permalink()函数.在循环内部你可以使用the_permalink($post->ID)虽然这个回声直接输出.这是wordpress.org的参考资料.
https://developer.wordpress.org/reference/functions/get_permalink/ https://codex.wordpress.org/Function_Reference/the_permalink