$args = array( 'post_type' => 'my_custom_type' 'cat' => $cat_id, ); $wp_query = new WP_Query( $args ); $wp_query->post->ID