-1

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?

Jeffrey Kevin Pry
  • 3,266
  • 3
  • 35
  • 67
user2966586
  • 165
  • 2
  • 11
  • `add_query_arg()` is not a php core function. It is a WordPress function. So, the example is not a generic purpose code. Moreover, the wording of this question is poor and doesn't really expose the problem. Finally, the question is a duplicate of http://stackoverflow.com/questions/1251582/beautiful-way-to-remove-get-variables-with-php. – Denis V Jan 12 '14 at 20:48

1 Answers1

0

Try this

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

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

Community
  • 1
  • 1
zzlalani
  • 22,960
  • 16
  • 44
  • 73