Renish Khunt
Renish Khunt

Reputation: 5824

Wordpress set taxonomy on post?

hello this is my code to select taxonomy for post by post id.

this is my code and this code is doesn't work please help.

wp_set_post_terms( '2653', array('Bus'), 'category_type_bus');

this is my code when i run that code.and then after checked in backend. the Bus is not selected please tell where i am wrong.

thank you.

Upvotes: 0

Views: 94

Answers (1)

Ram Sharma
Ram Sharma

Reputation: 8809

I feel you are missing one more parameter which is option. You can try to pass true so that it can append to existing.

try something like that

wp_set_post_terms( '2653', array('Bus'), 'category_type_bus',true);

if above things not work than try to pass the term id instead of name. something like this

wp_set_post_terms( '2653', array( 5 ), 'category_type_bus',true);

Upvotes: 1

Related Questions