Alicia St Rose
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:
I need the event-tag term to be the term of the current taxonomy. That's where I'm stuck.
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'
)
),
)
); ?>
I need the event-tag term to be the term of the current taxonomy. That's where I'm stuck.
Is that code in a loop in your template? If so, you might need to provide the surrounding code.
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
taxonomy-event-tag.php
eo-loop-events.php
Try getting the term using:
$term_slug = get_query_var( 'term' );
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I worked out the code and got it working. Terry set me on the right track, however!