• Resolved tomken9x

    (@tomken9x)


    I have some custom taxonomy in my WordPress site, but I want to hide a custom taxonomy post from my Recent posts. I have this code:
    $c1 = array(
    ‘post_type’ => ‘post’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘quality’,
    ‘field’ => ‘id’,
    ‘terms’ => 123,
    ))
    );
    $c2 = array(
    ‘post_status’ => ‘publish’,
    ‘post__not_in’ => $c1,
    ‘posts_per_page’ => 10,
    );
    $recent = new WP_Query($c2);
    while ($recent->have_posts()) : $recent->the_post();
    But unfortunately it doesn’t work. How should I do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try using the operator taxonomy parameter to exclude those posts:

    $c2 = array(
        'post_status' => 'publish',
        'posts_per_page' => 10,
        'tax_query' => array(
            array(
                'taxonomy' => 'quality',
                'field' => 'id',
                'terms' => 123,
                'operator' => 'NOT IN',
            )
        ),
    );

    Hope that helps.

    Thread Starter tomken9x

    (@tomken9x)

    Unbelievable, it worked, you saved me. Thank you very very much!
    Concatenation! I use this code for “wp tab widget” plugin of you , i very love it and mod it to show advanced posts ^^

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to hide custom taxonomy posts from recent posts’ is closed to new replies.