set 301 redirect after using wp_delete_post() function

I use wp_delete_post() function to delete a custom post type in WordPress. I have a question regarding the custom post type permalink after the deletion, is there a way to set an automatic 301 redirect for all deleted custom post types to a specific page from my website?

For example if someone access a deleted post (ex: mysite/customposttype/test), will be redirected to a specific page (mysite/newpage) with 301 redirect.

Thank you!

Read more here: set 301 redirect after using wp_delete_post() function

Leave a Reply

Your email address will not be published. Required fields are marked *