场景:我博客上的文章的urls和标题通常都很长。每当我或其他人发推文时,我找不到任何空间来添加标签或引用的转发文本。我不想缩短帖子的标题,所以另一种选择是缩短url。为此,我想以这种格式从wordpress帖子中抓取快捷链接
http://mydomain.com/?p=(post
你能告诉我怎么做吗?
发布于 2016-07-01 03:02:58
使用wp获取快捷链接
根据数字ID返回URL,即http://example.com/?p=1234
https://codex.wordpress.org/Function_Reference/wp_get_shortlink
用法<?php $short_link = wp_get_shortlink(); ?>或<?php echo wp_get_shortlink(); ?>
源文件wp_get_shortlink()位于wp-includes/link-template.php中。
发布于 2012-05-15 14:59:07
您可以转到设置-> Permalinks并将其设置为“default”(如果愿意,也可以设置为“numeric”),然后调用
<?php the_permalink() ?>在你的“tweet this”链接里。
或者您可以使用以下命令:Twitter Friendly Links WordPress Plugin
https://stackoverflow.com/questions/10595213
复制相似问题