Skip to main content

Try this:

$jobsTerms = get_terms('jobtype',array( 'taxonomy' => 'jobtype' )); 
foreach($jobsTerms as $term){
    $checked = (has_term($term->slug, 'jobtype', $post_id$post->ID)) ? 'checked="checked"' : '';
    echo "<label for='term-" . $term->slug . "'>" . $term->name . "</label>";
    echo "<input type='checkbox' name='term" . $term->slug . "' value='" . $term->name . "' $checked />";
}

Replace $post_id with whatever you need to get the ID, I'm not sure where exactly this code goes. It may be $post->ID.

Try this:

$jobsTerms = get_terms('jobtype',array( 'taxonomy' => 'jobtype' )); 
foreach($jobsTerms as $term){
    $checked = (has_term($term->slug, 'jobtype', $post_id)) ? 'checked="checked"' : '';
    echo "<label for='term-" . $term->slug . "'>" . $term->name . "</label>";
    echo "<input type='checkbox' name='term" . $term->slug . "' value='" . $term->name . "' $checked />";
}

Replace $post_id with whatever you need to get the ID, I'm not sure where exactly this code goes. It may be $post->ID.

Try this:

$jobsTerms = get_terms('jobtype',array( 'taxonomy' => 'jobtype' )); 
foreach($jobsTerms as $term){
    $checked = (has_term($term->slug, 'jobtype', $post->ID)) ? 'checked="checked"' : '';
    echo "<label for='term-" . $term->slug . "'>" . $term->name . "</label>";
    echo "<input type='checkbox' name='term" . $term->slug . "' value='" . $term->name . "' $checked />";
}

Replace $post_id with whatever you need to get the ID, I'm not sure where exactly this code goes. It may be $post->ID.

Source Link

Try this:

$jobsTerms = get_terms('jobtype',array( 'taxonomy' => 'jobtype' )); 
foreach($jobsTerms as $term){
    $checked = (has_term($term->slug, 'jobtype', $post_id)) ? 'checked="checked"' : '';
    echo "<label for='term-" . $term->slug . "'>" . $term->name . "</label>";
    echo "<input type='checkbox' name='term" . $term->slug . "' value='" . $term->name . "' $checked />";
}

Replace $post_id with whatever you need to get the ID, I'm not sure where exactly this code goes. It may be $post->ID.