[Solved] Front end post form won’t post categories to custom post type


I see two problems with your code:

First You named your custom taxonomy type which is a Reserved Term

Second You are trying to insert your taxonomy terms using 'post_category' which wont get the job done. What you can do is either create a `’tax_input’ => array(‘ in your new post array e.g:

$new_post = array(
    'post_title'   => stripslashes($title),
    'post_content' => stripslashes($description),
    'tags_input'   => stripslashes($tags),
    'post_status'  => 'publish', // Choose: publish, preview, future, draft, etc.
    'post_type'    => 'user_lists', //'post',page' or use a custom post type if you want to
    'tax_input'    => array(
        'type'  => $_POST['type'],
        'state' => $_POST['state'],
    )
);

or you can leave your code the way it is and use wp_set_object_terms
after you get the new post ID e.g:

//SAVE THE POST
$pid = wp_insert_post($new_post);
wp_set_object_terms( $pid, $_POST['type'], 'type' );
wp_set_object_terms( $pid, $_POST['state'], 'state' );

Update:

You need to make your register_taxonomy calls inside a hooked function so move then into your portfilio_register function and also give the action hooks priority e.g:

add_action('init', 'portfolio_register',100); 
function portfolio_register() {

    $labels = array(
        'name' => _x('User Lists', 'post type general name'),
        'singular_name' => _x('User List', 'post type singular name'),
        'add_new' => _x('Add New', 'list item'),
        'add_new_item' => __('Add New List'),
        'edit_item' => __('Edit List Item'),
        'new_item' => __('New List Item'),
        'view_item' => __('View List Item'),
        'search_items' => __('Search Lists'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
    'labels' => $labels,
    'public' => true, 
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => get_stylesheet_directory_uri() . '/img/cutleries.png',
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'show_admin_column' => true,
    'menu_position' => null,
    'taxonomies' => array('post_tag', 'list_type', 'list_state'),
    'supports' => array('title',
        'editor',
        'author',
        'custom-fields',
        'comments')
          );

    register_post_type( 'user_lists' , $args ); 
    register_taxonomy("list_type", array("user_lists"), array("hierarchical" => true, "label" => "List Types", "singular_label" => "List Type", "rewrite" => true, 'show_admin_column' => true,)); 
    register_taxonomy("list_state", array("user_lists"), array("hierarchical" => true, "label" => "List State", "singular_label" => "List State", "rewrite" => true, 'show_admin_column' => true,));
}

add_action('init', 'catch_save_form',101);

As for your shortcode function you should return a value on a shortcode and not echo or print it out.

10

solved Front end post form won’t post categories to custom post type