I found the solution and let me post in reply so that other members can get help. the_permalink() wordpress functions is used for this purpose. I used this and solve my problem. Thanks to @AndyWarren.
Here is the function: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_permalink