I'm using the plugin Post from site, which sets up a WP front end writer. I changed some line of code because I need to select categories with checkboxes and not with a multiple select (as it was originally in the plugin). Unfortunately it doesn't work: there is a checkbox in the front end writer, now, but checking boxes just does nothing: the post is saved without categories.
Here's the code which handles the taxonomy selection:
public function get_taxonomy_list( $taxonomy ){
$terms = get_terms($taxonomy, array(
'hide_empty' => 0
));
if (!$terms || empty($terms)) return '';
//preg_match_all('/\s*<input class="(\S*)" value="(\S*)" type="checkbox">(.*)<\/input>\s*/', $terms, $matches, PREG_SET_ORDER);
$out = apply_filters( 'pfs_taxonomy_label', "<label for='terms_$taxonomy'>Seleziona i corsi</label>", $taxonomy );
foreach ($terms as $term){
if (is_taxonomy_hierarchical($taxonomy))
$out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->term_taxonomy_id}' name='{$term->term_taxonomy_id}' /> {$term->name}<br />";
else
$out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->name}' name='{$term->name}' /> {$term->name}";
}
$out .= "<br />\n";
return apply_filters("pfs_{$taxonomy}_list",$out);
}
and here's the code which saves the post and the taxonomy (which I didn't change):
$postarr['tax_input'] = (array_key_exists('terms',$pfs_data)) ? $pfs_data['terms'] : array();
$post_id = wp_insert_post($postarr);