dse323222
2013-12-07 06:20
浏览 82
已采纳

Wordpress在帖子上设置分类法?

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.

图片转代码服务由CSDN问答提供 功能建议

你好,这是我的代码,为帖子ID选择分类。

这是我的代码,这段代码不起作用请求帮助。

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

当我运行该代码时,这是我的代码。然后在后端检入后。 未选择总线请告诉我哪里错了。

谢谢。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongxiequ3724 2013-12-07 06:32
    已采纳

    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);
    
    打赏 评论

相关推荐 更多相似问题