简体   繁体   中英

How to Set the Category When Posting to WordPress from Python Using Wordpresslib

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.

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

post.categories = ["4"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM