How To Add Short URL Below Posts In WordPress

How To Add Short URL Below Posts In WordPress

In this tutorial, I’ll show you how to add a short URL below posts in WordPress without using any plugin. This will encourage your visitors to share your posts with the help of easy short URLs. As I said, we’re not going to use any external plugin or would have to host anything on our server.

We will use TinyURL’s API to shorten our URLs on the go. It pretty easy, we just need to place two small snippets on our WordPress theme.

Add following snippet to your current theme’s functions.php file:

Now, add following snippet to your single.php file or wherever you want to show your short URL:

In addition, you can also use tr.im’s API for this job but putting following code to your functions.php file: