I
I
Ilya2017-09-13 12:22:04
CMS
Ilya, 2017-09-13 12:22:04

How to remove posts with matching tags from custom taxonomy?

You need to display posts that have at least 1 tag matching the current (open) post and you need to exclude posts from the 'upcoming' category from the selection. I can't figure out how to replace 'tag__in' for custom taxonomy, help guys out:

$args = array(
    'post_type' => 'webinar',
    'posts_per_page' => 3,
    'post__not_in' => array(get_the_ID()),
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'post_tag',
            'field' => 'id',
            'terms' => wp_get_post_tags(get_the_ID(), array('fields' => 'ids'))

        ),
        array(
            'taxonomy' => 'webinars',
            'field' => 'slug',
            'terms' => 'upcoming',
            'operator' => 'NOT IN'
        )
    )
);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question