Title: WP function for rewriting raw URL?
Last modified: August 19, 2016

---

# WP function for rewriting raw URL?

 *  [termserv](https://wordpress.org/support/users/termserv/)
 * (@termserv)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/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:
 * [http://site.url/?p=page-title#comment-45](http://site.url/?p=page-title#comment-45)
 * Into this:
 * [http://site.url/category/page-title/#comment-45](http://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.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)
 * [permalinks](https://wordpress.org/support/topic-tag/permalinks/)
 * [rewrite url](https://wordpress.org/support/topic-tag/rewrite-url/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [termserv](https://wordpress.org/support/users/termserv/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/wp-function-for-rewriting-raw-url/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
