Link to home
Start Free TrialLog in
Avatar of Alicia St Rose
Alicia St RoseFlag for United States of America

asked on

display posts from current taxonomy archive and post with current AND second taxonomy term in same archive

I've got a taxonomy called event-category and another called event-tag.

I'm using the taxonomy-event-tag.php to display any events that are tagged with a specific term. In addition to being tagged they are also given an event-category past-events. The current events show up in the loop in the template. I'd like to have an additional section below that displays past events that share the current tax term.

the taxonomies are event-category and event-tag.

I'm about to pull my hair out trying to figure this out. Been on Google for hours. I'm missing a key understanding, I'm sure. If some one can get me started in the right direction, I'd  love it!!

I've got the follow code:

<?php $args = array(
    'posts_per_page' => -1, 
    'post_type' => 'event',  
    'tax_query' => array(
        'relation' => 'AND'
        array(
            'taxonomy' => 'event-tag',  
            'field' => 'slug',
            'terms' => array(
                'MAT' //I need this to be the term of the current taxonomy!
            )
        ),
        array(
            'taxonomy' => 'event-category',   
            'field' => 'slug',
            'terms' => array(
                'past-events'
            )
			    ),
			  )
			); ?>

Open in new window


I need the event-tag term to be the term of the current taxonomy. That's where I'm stuck.
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Is that code in a loop in your template? If so, you might need to provide the surrounding code.
Avatar of Alicia St Rose

ASKER

I'm attaching the files. There's the taxonomy archive file  and the template part that's being called into the archive.

taxonomy-event-tag.php

eo-loop-events.php
Try getting the term using:
$term_slug = get_query_var( 'term' );

Open in new window

SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm trying to list the Posts that share current queried taxonomy term and the term "past-events". Is this code going to show the posts? or the Term slug?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I worked out the code and got it working. Terry set me on the right track, however!