Please find below code to get custom posts:-
$args = array('post_type' => 'all_photos','tax_query' => array(array(
'taxonomy' => 'photo',
'field' => 'term_id',
'terms' => $term_id,
),
),
);
$post_query = new WP_Query($args);