Question

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

Was it helpful?

Solution

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 !

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top