从url中删除query_arg

I am adding parameters to my url using

<?php 
  echo esc_attr( add_query_arg( 'past_events', '' ) ); 
?>

when a link is clicked. This works perfectly but how would I remove past-events from the URL if another button is clicked?

Try this

$url = preg_replace('/\?.*/', '', $url);

Have a look at this answer https://stackoverflow.com/a/4270683/829533