get_terms showing all categories instead of the ones assigned to a specific post

I have 3 posts in my custom post type (‘careers’). I registered a custom taxonomy of (‘career_categories’).

I created 3 posts and assigned two of them with a category of “Full-Time” and one with “Part-Time”.

I am using the following code in my loop:

$terms = get_terms( ‘career_categories’, array( ‘hide_empty’ => true, ) );

$html_out .= ‘<td class=”column-‘. $col++ .'”>’;
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) :
foreach( $terms as $term) :
$html_out .= $term->name;
endforeach;
endif;
$html_out .= ‘</td>’;

On the front-end this is displaying both categories on each post. I need it to show only the category selected for the post.

Currently
Job 1 – Full-TimePart-Time
Job 2 – Full-TimePart-Time
Job 3 – Full-TimePart-Time

Expected
Job 1 – Full-Time
Job 2 – Full-Time
Job 3 – Part-Time

Read more here:: get_terms showing all categories instead of the ones assigned to a specific post

Leave a Reply

Your email address will not be published. Required fields are marked *