douse8732
2017-03-28 15:18 阅读 41

如何使用Wordpresslib从Python发布到WordPress时设置类别

There's not much in the documentation of this old Wordpresslib module on how to post to a specific category. Looking through the code of the module itself shows lots of category related classes in it.
('World' is a category already set on the WP site I'm posting to.) I've tried these below but everytime the category of the post on WP is "Uncategorized"...

post.setPostCategories = ["World"]
post.categories = ["World"]
post.WordPressCategory = ["World"]

Not sure if this involves keys or something or if I'll have to import another module to set the category.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doufusi2013 doufusi2013 2017-03-28 15:19

    The categories are already set on your WP site as numbers.
    Post to them like this when using the Wordpresslib module...

    post.categories = ["4"]
    
    点赞 评论 复制链接分享

相关推荐