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.

  • please post complete code. Commented Apr 24, 2017 at 9:45
  • What do you mean with the complete code? what more do i need to get posts for a specific category? i can throw in all the HTML if you wish, but i dont think you would want all that :)
    – Mac
    Commented Apr 24, 2017 at 9:52

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(
            '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.

  • Still returns an empty array :(
    – Mac
    Commented Apr 24, 2017 at 10:53
  • one more thing. value of cat should be int not an array. so, you need to change that line too Commented Apr 24, 2017 at 11:18
  • Still not working :( its a custom post and a custom taxonomy, does that matter?
    – Mac
    Commented Apr 24, 2017 at 11:27
  • Yes, That matters. you need to put value of the post_type as well. It defaults to post . More details about the WP_Query class can be found here. Commented Apr 24, 2017 at 11:29
  • i have edit'ed op, that brings me some of the posts but not all of them :S
    – Mac
    Commented Apr 24, 2017 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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