Question: Echo WordPress post link in ID formart


Echo WordPress post link in ID formart

Answers 0
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 get_permalink(); functions prints the URL in format defined in WordPress Permalink settings.

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. So I wrote this following code:

<?php echo "?p=".get_the_ID(); ?>

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?

Answers to

Echo WordPress post link in ID formart

Source Show
◀ Wstecz