Echo WordPress post link in ID formart
|Added at||2016-12-31 10:12|
I'm working on social like, share and comments plugins in which I want to print the current URL of the post. The
The problem is if have comments and likes on a post and I change the permalink structure from settings the new permalink will be treated as new links and all the likes and comments will be shown as if they are on new posts.
So instead of creating links with slug names, I'm thinking to print the ID of the posts.
e.g. example.com/?p=123 So I wrote this following code:
This code works everywhere but the social buttons and comments. It only prints ?p=123
I know I can add the website url while printing the URL with ID. But instead of doing all this I was thinking is there any efficient way to directly print the desired URL format irrespective of what the permalink structure is?