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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: