lundi 5 octobre 2015

Wordpress, add post to custom taxonomy's category

I am trying to add a post to a category under taxonomy cate. The code I am using is:

$user = get_user_by( 'email', $_POST['user'] );
$id = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_date'     => date('Y-m-d H:i:s'),
    'post_author'   => $user->ID,
    'taxonomy' => ('cate'),
    'post_type'     => 'ad',
    'post_category' => array(425),
    'post_status'   => 'publish',
); 
 $user_id = wp_insert_post($id);
if ( ! is_wp_error( $user_id ) ) {
   $odgovor["success"] = 1;

}

The post is added but it's added under category 'uncategorized" and not under desired category ID. This system works properly when custom post type is not used. (In this case taxonomy 'cate')

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire