I'm sorry, I speak a little English.

$x = wp_insert_term( 'Duper', 'category' );
// $x = array ( 'term_id'=> 692, 'term_taxonomy_id'=> 692 );

The term_id and the term_taxonomy_id always the same?

Which one should I use as a category ID?


wp_insert_post( array( 'post_category'=> array( $x [ 'term_id' ] ) ) );
// OR
wp_insert_post( array( 'post_category'=> array( $x [ 'term_taxonomy_id' ] ) ) );


  • Yes, they are normally the same, but not necessarily be always the same, so just check the documentation for the function you're using and you'd know which field should be used. As for wp_insert_post(), though, you should use term_id.
    – Sally CJ
    Aug 6 '21 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.