只需更改的第二个参数get_edit_post_link(), 这是$context 并默认为display. 该参数决定了如何输出符号和字符(即。&), 默认编码为& (因为默认上下文是显示URL,因此& 已编码)。
使用带有重定向的URL时,您需要使用edit (或除display) 上下文:
$edit_post_link = get_edit_post_link( $order_id, \'edit\' );
wp_redirect( $edit_post_link );
显示URL时,您可以使用
display 上下文:
$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 &