-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a category while posting to wordpres? #52
Comments
You can find existing categories by:
Each
to set one category. You can select multiple categories too. BTW, I just noticed that creating a tag requires certain reputation in stackoverflow, which I don't have. I'll change the documentation until it matches my reputation on overestimation :) |
Hi thanks for the explanation I did as you suggested but I have a different Problem now, if i run this code: Wordpress wp = new Wordpress(username, password, xmlRpcUrl);
Post post = new Post();
post.setPost_title("test");
DateTime date = new DateTime(1990, 12, 1, 1, 1);
post.setPost_date(date.toDate());
post.setPost_status("pending");
post.setPost_excerpt("test test");
List<Term> terms = wp.getTerms("category");
terms.removeIf(term -> !term.getName().equals("test"));
post.setTerms(terms);
wp.newPost(post); i get the following exception: Exception in thread "main" net.bican.wordpress.exceptions.InsufficientRightsException
at net.bican.wordpress.Wordpress.newPost(Wordpress.java:1251)
at test.main(test.java:39) I'm testing this with and Administrator account on a wordpress.com hosted site. I was able to post with categories to this blog before by pasing this hashmap to a xmlrpc client: HashMap hmContent = new HashMap();
hmContent.put("title", "test");
hmContent.put("description", "test test");
hmContent.put("post_status", "pending");
hmContent.put("categories", new String[]{"test"}); I'm using jwordpress version 0.6.2 |
Wordpress xml-rpc doc says it's one of the following:
But I always notice inconsistencies in documentation and error codes of the xml-rpc part of wordpress, should debug. I don't currently have immediate access to a wordpress installation. I'll get back in a day. |
It's a "mysite".wordpress.com Administrator account according to wordpress the Administrator Role encompasses the following capabilities: So i guess 1+2 are not relevant. 3 also because there is only one user on this site. 4 also because i don't pass sticky. 5 i don’t know, if I post via wp-admin I can assign categories to a pending post so i guess it is also not relevant. 7 should be also not relevant because this is the only term named "test" on this blog. |
This seems to be something I definitely overlooked, but hopefully fixed. I released a new version, please use 0.6.3. It should be visible on maven central. Meanwhile, you can use the jar file in the releases section. Please let me know if it works for you. |
I can confirm that it works now. Good job thank you! |
Hi, i tried to post this question to stackoverflow but the recommended tag "wordpress-java" does not exist.
I want to use the wordpressj api client to post to wordpress via xmlrpc.
I'm using it like this:
How can I add a category to this post?
The text was updated successfully, but these errors were encountered: