Pergunta

I have a custom-taxonomy for a custom-post-type just like categories.

I've used the standard loop in my taxonomy-event_type.php template so far …

if ( have_posts() ) : while ( have_posts() ) : the_post(); 

This meant that the template only showed the posts associated with the current term (category) the post was in. So on url/event_type/workshops only all posts that were set to "workshops" in the backend would appear.

Now i've changed that standard loop to a custom loop where I'm passing some args so I can sort the posts by a meta-value (the event date)

$args = array(
    "post_type" => "wr_event",
    "meta_key" => "_wr_event_date",
    "orderby" => "meta_value_num",
    "order" => "ASC"
    //"terms" => 
    );

    $wr_events = new WP_Query( $args );

    if ( $wr_events->have_posts() ) : while ( $wr_events->have_posts() ) : $wr_events->the_post();

This works perfect. Only thing. It breaks the standard behaviour for the term (category) I'm currently viewing.

So with this custom loop when viewing url/event_type/workshops or url/event_type/lectures always the same posts appear! How can I again view only the posts associated with the current term "workshops" or "lectures"?

Thank you for your help!

edit:

if I do …

$current_cat = get_query_var( 'event_type' );
echo $current_cat;

$args = array( …

The $current_cat holds the right term (category) I'm currently in. Only problem is that the posts in the loop are always the same. How can I filter by this term?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top