Title: programmatically create a redirect
Last modified: July 28, 2020

---

# programmatically create a redirect

 *  Resolved [ramnathk](https://wordpress.org/support/users/ramnathk/)
 * (@ramnathk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/programmatically-create-a-redirect/)
 * Hi there,
    I have a CPT with a custom field X(using ACF). I would like to setup
   a redirection like site.com/abc (where abc is the value of X for that post) to
   redirect to the post. My permalink uses the post name and I need that for SERP
   reasons.
 * I was hoping to be able to call into SRM from a save_post hook, but can’t find
   documentation on how to do it. Can you help?

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

 *  Thread Starter [ramnathk](https://wordpress.org/support/users/ramnathk/)
 * (@ramnathk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/programmatically-create-a-redirect/#post-13183025)
 * As a follow up – I’ve gone ahead and called `srm_create_redirect` to create the
   redirects. Is that the recommended way of doing things?
 *  [Tung Du](https://wordpress.org/support/users/dinhtungdu/)
 * (@dinhtungdu)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/programmatically-create-a-redirect/#post-13186615)
 * [@ramnathk](https://wordpress.org/support/users/ramnathk/) Yes, you can use `
   srm_create_redirect` to create redirects. That function is used internally in
   CLI commands.
 *  Thread Starter [ramnathk](https://wordpress.org/support/users/ramnathk/)
 * (@ramnathk)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/programmatically-create-a-redirect/#post-13187152)
 * Awesome thanks

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

The topic ‘programmatically create a redirect’ is closed to new replies.

 * ![](https://ps.w.org/safe-redirect-manager/assets/icon.svg?rev=2791413)
 * [Safe Redirect Manager](https://wordpress.org/plugins/safe-redirect-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/safe-redirect-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/safe-redirect-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/safe-redirect-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/safe-redirect-manager/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)

 * 3 replies
 * 2 participants
 * Last reply from: [ramnathk](https://wordpress.org/support/users/ramnathk/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/programmatically-create-a-redirect/#post-13187152)
 * Status: resolved