WP function for rewriting raw URL?
-
I’ve made a custom SQL query to the WordPress database which collects the latest comments from a certain (given) category. I want to get the permalink URL to generate a direct URL to the comment, and I am wondering if anyone knows if there’s a function in WordPress for that?
I basically want to get an URL like this:
https://site.url/?p=page-title#comment-45
Into this:
https://site.url/category/page-title/#comment-45
And I want to be able to update the permalink structure settings in WP without having to update the function.
I’ve tried to link up site.url/?p=page-title#comment-45 and it rewrites correctly, but it removes the #comment-45 at the end of the URL, which results in the browser not scrolling down to the comment.
- The topic ‘WP function for rewriting raw URL?’ is closed to new replies.