Your problem is that you’re using Reserved Terms. error
is a reserved term, you can’t use it.
To get around this, you could intercept the request early, and do a redirect, changing the query parameters in the process. For example, handling a link
get parameter:
add_action( 'wp' , 'reserved_term_intercept' );
function reserved_term_intercept(){
global $wp_query;
if( $wp_query->queried_object_id == 72 && isset( $_GET["link"] ) ){
wp_redirect( get_permalink( 72 ) . "?newlink=" . urlencode( $_GET["link"] ) . "&nonce=" . wp_create_nonce( 'nonce-name' ) );
exit;
}
}
Then handle the new variable:
add_action( 'wp_head' , 'reserved_term_handling' );
function reserved_term_handling(){
if( wp_verify_nonce( $_GET["nonce"], 'nonce-name' ) == TRUE && isset( $_GET["newlink" ) ){
printf( '<a href="https://wordpress.stackexchange.com/questions/185304/%s">Hello World!</a>', esc_url( urldecode( $_GET["newlink"] ) ) );
}
}
wp_head
may not be the most appropriate hook to run the code on, probably init
instead