Title: Filter post_link to use an external URL
Last modified: February 2, 2021

---

# Filter post_link to use an external URL

 *  Resolved [rossberenson](https://wordpress.org/support/users/rossberenson/)
 * (@rossberenson)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/filter-post_link-to-use-an-external-url/)
 * I’m trying to filter ‘post_link’, ‘page_link’, ‘post_type_link’. The Permalink
   Manager Plugin overrides these and prevents me from filtering them. This makes
   sense since the plugin is now managing the permalinks but I have a case where
   I want the permalink to link to an external source. I tried using “permalink_manager_filter_default_post_uri’
   and then loading the custom ACF field value but the value is sanitized and the
   external URL breaks.
 * I have a URL field for external links. I would like that to be the permalink,
   automatically if the field has a value. I can obviously check to see if this 
   field has a value, if so, print it, else use the default url. However, I’m trying
   to avoid that unnecessary code. Is there another hook that I could use? Wherever
   the post appears, I would like its permalink to be the external URL that was 
   provided. Thanks for any assistance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/filter-post_link-to-use-an-external-url/#post-13990750)
 * Hi [@rossberenson](https://wordpress.org/support/users/rossberenson/),
 * did you possibly try to register tour new hooks with the priority higher than“
   99”?
 * Example:
 *     ```
       add_filter( 'page_link', 'your_custom_filter', 100, 2);
       add_filter( 'post_link', 'your_custom_filter', 100, 2);
       add_filter( 'post_type_link', 'your_custom_filter', 100, 2);
       ```
   
 * Best regards,
    Maciej
 *  Thread Starter [rossberenson](https://wordpress.org/support/users/rossberenson/)
 * (@rossberenson)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/filter-post_link-to-use-an-external-url/#post-13992322)
 * [@mbis](https://wordpress.org/support/users/mbis/) – Thanks for that suggestion.
   That worked. Sometimes you’re oblivious to the obvious.
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/filter-post_link-to-use-an-external-url/#post-13992606)
 * No problem [@rossberenson](https://wordpress.org/support/users/rossberenson/)
   🙂 I am glad that you managed to get it working.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Filter post_link to use an external URL’ is closed to new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

## Tags

 * [external](https://wordpress.org/support/topic-tag/external/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [post_link](https://wordpress.org/support/topic-tag/post_link/)
 * [post_type_link](https://wordpress.org/support/topic-tag/post_type_link/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 3 replies
 * 2 participants
 * Last reply from: [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/filter-post_link-to-use-an-external-url/#post-13992606)
 * Status: resolved