WordPress.org

Ready to get started?Download WordPress

Forums

how to automatically add taxonomy keyword when a post published (6 posts)

  1. zagriyen
    Member
    Posted 3 years ago #

    Hi all,
    i want add automatically keyword to a taxonomy when a post published ,
    how to make this ?

  2. zagriyen
    Member
    Posted 3 years ago #

    i tried wp_set_object_terms , but tag must be already exist :(

  3. zagriyen
    Member
    Posted 3 years ago #

    i found this

    // Create the post array
    $post = array(
        'ID' => 5,
        'tags_input' => 'foo,bar,baz');        
    
    // Update the post
    wp_update_post($post);

    but now how use this with custom taxonomy

  4. zagriyen
    Member
    Posted 3 years ago #

    i tried this

    wp_set_object_terms($post_id,'test', 'test_taxonomy', false );

    but the taxonomy not assigned to the post

  5. joehuffman2
    Member
    Posted 3 years ago #

    have you tried set_post_terms? and passed a variable into a parameter? I feel like set_post_terms and there might be a insert_term, but not quite sure.

    You also have to add a hook (hook it onto when something occurs) onto the wordpress publish function, I believe.

  6. zagriyen
    Member
    Posted 3 years ago #

    i tried this too, and it don't working :(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags