My Setup

I have a custom post type “zap_apartments” with 2 custom taxonomies “zap_audience” & “zap_cities”.

I wrote some RewriteRules to access all “zap_apartments” for a “zap_audience” + “zap_cities” assigned. It is to filter the results with seo-friendly URLs:

it makes a request like my-url.de/holiday/cologne/
internally an url like my-url.de/index.php?post_type=zap_apartments&zap_audience=holiday&zap_cities=cologne

My Problem

When I try to access the taxonomy information on the custom archive page I only get 1 taxonomy returned:

print_r( get_queried_object() );

prints:

stdClass Object
(
    [term_id] => 17
    [name] => Cologne
    [slug] => cologne
    [term_group] => 0
    [term_taxonomy_id] => 17
    [taxonomy] => zap_cities
    How to get_queried_object on multiple objects? => 
    [parent] => 0
    [count] => 2
    [filter] => raw
)

Is there any way I can get the other assigned taxonomy “zap_audience” too?

I already asked google, but couldn’t find anything useful. I also tried to access any value by $_GET['zap_audience'] but it’s empty.

Please help! Thank you!

1 Answer
1

You almost had it with $_GET['zap_audience'], but not quite, since it isn’t passed in as a GET variable.

It is however a query variable, so try these:

$post_type = get_query_var( 'post_type' );
$audience  = get_query_var( 'zap_audience' );
$city      = get_query_var( 'zap_cities' );

Also +1 for prefixing your taxonomy types with zap_

Leave a Reply

Your email address will not be published. Required fields are marked *