1

I'am trying to filter my archive page by clicking links. When clicked they execute the add_query_arg command.

Everything works fine so far.

But now i want to add combinations within the same custom taxonomy.

ex: http://url.com/archive/ '?events=test&events=test2'

now the question, how to add two times the same argument with add_query_arg without overwriting the first one ? And how to get them again ?

Hope someone can help me out here.

Best regards

2
  • You can pass two values as comma separated in a single parameter events. And later parse value correctly in your page. Commented Aug 13, 2014 at 8:24
  • that sounds good ! i'm going to try that. Thanks !!!
    – AnC
    Commented Aug 13, 2014 at 8:39

1 Answer 1

0

Nilambar's comment solved this for me.

"You can pass two values as comma separated in a single parameter events. And later parse value correctly in your page. – Nilambar"

I use this to get posts with tag1 OR tag2:

echo '<a href="'.esc_attr(add_query_arg( 'events', 'tag1,tag2')).'">Linkname</a>';

And to get all posts with tag1 AND tag2 simply use "+" instead of ",":

echo '<a href="'.esc_attr(add_query_arg( 'events', 'tag1+tag2')).'">Linkname</a>';

Thanks Nilambar !

1
  • Glad that I could be of some help :-) Commented Aug 13, 2014 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.