[wp-hackers] Are there any implications about using wp_redirect( add_query_arg( '', '' ) )?
nikolov.tmw at gmail.com
Tue Feb 16 13:17:32 UTC 2016
Well, it actually works fine with the example I gave.
Here, say I'm on http://example.com/page1/?a=b&c=d
Then I call add_query_arg( '', '' ) - omitting the last parameter, which
makes it use the current request as the base URL.
This returns something like this: /page1/?a=b&c=d&
That last & is there because I tried to add an empty parameter, so there's
no key, but there's a trailing &(which should not be a problem as far as
My question wasn't about how to use add_query_arg() as much as it was about
whether there could be any issues by passing two empty parameters to the
function, since it technically expects those to be strings.
On Tue, 16 Feb 2016 at 14:57 James DiGioia <jamesorodig at gmail.com> wrote:
> add_query_args takes two or three parameters, depending on how you'd prefer
> to use it. See here:
> It's not automatically going to redirect using the current $_GET params;
> you need to specify in the function args what those params are supposed to
> On Tue, Feb 16, 2016 at 5:23 AM, Nikola Nikolov <nikolov.tmw at gmail.com>
> > Hi there,
> > I've found myself in situations where I want to reload the current URL
> > PHP - for instance after processing a $_POST request - and in some cases
> > would add a $_GET parameter to the URL(so add_query_arg() would be a
> > perfect fit there), but in others I don't need to do that. I found out
> > I can use
> > wp_redirect( esc_url_raw( add_query_arg( '', '' ) ) );
> > exit;
> > Used that way add_query_arg() seems to just give me a path and any $_GET
> > parameters currently present(for instance I would get
> > /product/my-product/). I'm escaping the URL with esc_url_raw(), but
> > to make sure there's nothing wrong with doing things that way.
> > Any thoughts?
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers