You just need to change the second parameter for get_edit_post_link(), which is $context and defaults to display. And that parameter determines how to output the ampersand character (i.e. &), which defaults to being encoded as & (because the default context is that the URL is being displayed, hence the & is encoded).
-
When using the URL with redirection, you would want to use the
edit(or anything other thandisplay) context:$edit_post_link = get_edit_post_link( $order_id, 'edit' ); wp_redirect( $edit_post_link ); -
When displaying the URL, you would use the
displaycontext:$edit_post_link = get_edit_post_link( $order_id, 'display' ); // Or you can simply ignore the second parameter: $edit_post_link = get_edit_post_link( $order_id ); var_dump( $edit_post_link ); // & becomes &