I have a normal WordPress settings page. It POSTs to options.php.
In options.php it uses wp_get_referer to redirect back to the page it came from.
I need to use remove_query_arg to remove an argument from the URL. Example:
.php?page=plugin_settings_page&tab=90
I need to remove the tab=90 part. How can I do this via options.php?
I have a normal WordPress settings page. It POSTs to options.php.
In options.php it uses wp_get_referer to redirect back to the page it came from.
I need to use remove_query_arg to remove an argument from the URL. Example:
https://www.example/wp-admin/admin.php?page=plugin_settings_page&tab=90
I need to remove the tab=90 part. How can I do this via options.php?
Share Improve this question asked Mar 17, 2017 at 20:18 Scott PatersonScott Paterson 234 bronze badges2 Answers
Reset to default 0Ended up using jQuery to do this. There might be a better way, but this works:
jQuery("input[name=_wp_http_referer]").val('admin.php?page=plugin_settings_page')
I would create a function that unset
the tab
parameter, then call that function using add_filter
to filter it from the query_vars
array. The example value of 20
may need to be changed depending on when the tab
parameter is currently being added.
add_filter('query_vars', 'remove_queryvars_param', 20 );
function remove_queryvars_param( $qvars )
{
unset($qvars['tab']);
return $qvars;
}