Get posts in custom post type categories

You can use any of Category Parameters for your WP_Query

  • cat (int) – use category id.
  • category_name (string) – use category slug.
  • category__and (array) – use category id.
  • category__in (array) – use category id.
  • category__not_in (array) – use category id.

    //list all posts by category
    $args = array(
        'post_type' => 'works', // NOT 'Works'
        // Add category id like this.
       'cat' => $cat_id
        );