Skip to main content
added 879 characters in body
Source Link
rand_user91
  • 57
  • 1
  • 3
  • 9

Can't get my WP_Query loop to work, cannot figure out why category__in won't work. Just want to pull certain categories FROM my custom post type

$args = array(
  'post_type' => 'bbt',
  'category__in' => array(90,89)
);

$loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

EDIT: Here is how the category was assigned:

    $labels = array(
    'name' => _x( 'Big Boys Toys Categories', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Types' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => __( 'Parent Tag' ),
    'parent_item_colon' => __( 'Parent Tag:' ),
    'edit_item' => __( 'Edit Tags' ),
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
);

// Register Custom Taxonomy
register_taxonomy('tagbbt',array('bbt'), array(
    'hierarchical' => true, // define whether to use a system like tags or categories
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'tag-bbt' ),
));

Can't get my WP_Query loop to work, cannot figure out why category__in won't work. Just want to pull certain categories FROM my custom post type

$args = array(
  'post_type' => 'bbt',
  'category__in' => array(90,89)
);

$loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

Can't get my WP_Query loop to work, cannot figure out why category__in won't work. Just want to pull certain categories FROM my custom post type

$args = array(
  'post_type' => 'bbt',
  'category__in' => array(90,89)
);

$loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

EDIT: Here is how the category was assigned:

    $labels = array(
    'name' => _x( 'Big Boys Toys Categories', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Types' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => __( 'Parent Tag' ),
    'parent_item_colon' => __( 'Parent Tag:' ),
    'edit_item' => __( 'Edit Tags' ),
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
);

// Register Custom Taxonomy
register_taxonomy('tagbbt',array('bbt'), array(
    'hierarchical' => true, // define whether to use a system like tags or categories
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'tag-bbt' ),
));
properly add code
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

Can't get my WP_Query loop to work, cannot figure out why "category__in"category__in won't work. Just want to pull certain categories FROM my custom post type

                        $args = array(
                            'post_type' => 'bbt',
                            'category__in' => array(90,89)
                        );

                        
                        $loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

Can't get my WP_Query loop to work, cannot figure out why "category__in" won't work. Just want to pull certain categories FROM my custom post type

                        $args = array(
                            'post_type' => 'bbt',
                            'category__in' => array(90,89)
                        );

                        
                        $loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

Can't get my WP_Query loop to work, cannot figure out why category__in won't work. Just want to pull certain categories FROM my custom post type

$args = array(
  'post_type' => 'bbt',
  'category__in' => array(90,89)
);

$loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories

Source Link
rand_user91
  • 57
  • 1
  • 3
  • 9

category__in not working on custom post type

Can't get my WP_Query loop to work, cannot figure out why "category__in" won't work. Just want to pull certain categories FROM my custom post type

                        $args = array(
                            'post_type' => 'bbt',
                            'category__in' => array(90,89)
                        );

                        
                        $loop = new WP_Query($args);

when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total from those categories