سؤال

I'm posting on Wordpress using the XMLRPC Api from Redstone. Although the post is made, the permalink is not set correctly. My code:

XmlRpcClient client = new XmlRpcClient("xmlrpc link...", true);
HashMap hmContent = new HashMap();
hmContent.put("title", "my post title");
hmContent.put("description", "my new post");
hmContent.put("permaLink", "my-brand-new-post"); <- this should be the permalink
token = client.invoke("metaWeblog.newPost", new Object[] {new Integer(1), 
                                                          "username", 
                                                          "password", 
                                                          hmContent, 
                                                          true} );

The permalink I have set is ignored and Wordpress had create a permalink based on the post title. What could cause this?

Edit: adding "wp_slug" value does the trick. Although "slug" isn't meant for this I think:

hmContent.put("wp_slug", "my-brand-new-post");
هل كانت مفيدة؟

المحلول

You could also try wordpress-java for setting the slug of the post. Have a look at this:

setWp_slug() in wordpress-java

Permalink and slug are different things, slug refers to the last "/" divided part of the permalink. You can't change a permalink in full, but you can change the last part via the slug.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top