0

我使用Redstone的 XMLRPC Api 在 Wordpress 上发帖。尽管发布了帖子,但未正确设置固定链接。我的代码:

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} );

我设置的永久链接被忽略,Wordpress 根据帖子标题创建了一个永久链接。什么可能导致这种情况?

编辑:添加“wp_slug”值就可以了。虽然“蛞蝓”并不意味着这个我认为:

hmContent.put("wp_slug", "my-brand-new-post");
4

1 回答 1

1

您也可以尝试使用 wordpress-java 来设置帖子的 slug。看看这个:

wordpress-java 中的setWp_slug()

永久链接和 slug 是不同的东西,slug 是指永久链接的最后一个“/”分隔部分。您不能完全更改永久链接,但可以通过 slug 更改最后一部分。

于 2012-03-07T07:37:38.133 回答