0

How to query post without specific categories for example "two"and "three"

$args = array(
            'post_type' => 'post',
            'orderby' => 'date',
            'order' => 'DESC',
            'showposts' => 3);

        $category_home = new WP_Query($args);

        if($wp_query->have_posts()) :
        while($wp_query->have_posts()) :
        $wp_query->the_post(); ?>
  • 1
    have you checked developer.wordpress.org/reference/classes/wp_query/… ? you might need to use the category ids for this. – Michael Feb 11 at 23:02
  • Are you trying to print the posts without including the category in the displayed HTML? Or trying to query posts without using categories? – Pixelsmith Feb 12 at 1:14
  • @Pixelsmith trying to quert post without using categories – nabuke Feb 12 at 1:18
0

I solved it like this array:

        <?php
        $args = array(
          'post_type' => 'post',
            'orderby' => 'date',
              'order' => 'DESC',
          'showposts' => '3',
          'cat' => '-1,-2,-3',


        );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.