Forums

wp insert post with custom taxonomies? (7 posts)

  1. ridesign
    Member
    Posted 2 years ago #

    Is it possible to use the "wp_insert_post" function with custom taxonomies?

    If I have created a cusom taxonomy called: people, and for a post I want to enter the name: "blair" how do I do this using wp_insert_post?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

  3. ridesign
    Member
    Posted 2 years ago #

    I am using that plugin but need a way to use these custom taxonomies when using the wp_insert_post function

  4. Juani
    Member
    Posted 2 years ago #

    You might look this function wp_set_post_terms( $post_ID, $tags, $taxonomy, $append ) in the codex http://codex.wordpress.org/Function_Reference/wp_set_post_terms.
    I use it in a form of my classifield site ;)

  5. nebagakid
    Member
    Posted 2 years ago #

    I am also trying to do this and it just doesn't got through!

    $post_id = wp_insert_post( array(
    		'post_author'	=> $user_id,
    		'post_title'	=> $post_title,
    		'post_content'	=> $post_content,
    		'tags_input'	=> $tags,
    		'post_status'	=> 'publish'
    	) );
    
        wp_set_post_terms( $post_id, $tax_mood       ,'mood'    ,false);
  6. nebagakid
    Member
    Posted 2 years ago #

    Eh, it seemed like my problem was my text fields were not prefixed with "post." I don't know why this was a problem, but as soon as I changed them, the entire world opened up to me.

  7. reza_mtl
    Member
    Posted 1 year ago #

    Hi, I'm having the same problem. Can you please elaborate on how you solved the problem?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic