Getting all custom posts with a certain category

I’m apparently retarded, and i have a hard time figuring out a simple task as getting all posts with a certain category. I tried:

  • query_posts()
  • New Query()

but im struggling to get something out of them

$args = array(
    'post_type'                     => 'fb',
    'fbcate_category'   => array(35),
    'order'                         => 'DESC', 
    'posts_per_page'                => -1,
);

$posts_array = new WP_Query($args);

I’ve tried similar with query_posts(), but I don’t get anything out except a empty array of that either.

1 Answer
1

$blabla = new Query($args); should be
$blabla = new WP_Query($args);

UPDATE
Your actual code should be something like:

$args = array(
    'post_type'         => 'fb',
    'tax_query'         => array(
        array(
            'taxonomy' => 'fbcate_category',
            'field'    => 'id',
            'terms'    => '35',
        ),
    ),
    'order'             => 'DESC', 
    'posts_per_page'    => -1,
);

$posts_array = new WP_Query($args);

Where taxonomy is your taxonomy name.

Let me know how it goes.

Leave a Comment