开发者

Is there a way to get the list of existing tags from a WordPress blog using AtomPub?

I'd like to be able to query a Wordpress blog for a list of existing tags so that they can be offered at the time that a new post is being created. Is this possible through AtomPub with Wordpress? I'm finding the documentation for Wordpress AtomPub support to be开发者_开发百科 lacking. I'm wondering if this is more of a restriction on AtomPub than on the Wordpress implementation.


It seems Atom does not have a concept of "tags", only "categories". As AtomPub is based on it, it only specifies a request for categories.

The WordPress AtomPub implementation calls get_categories() directly, which, of course, defaults to the category taxonomy. However, you can filter the arguments via get_categories_taxonomy, and change the taxonomy argument to an array that includes post_tag. You would of course only enable this filter when there is an AtomPub request.

When a post is created or updated WordPress only looks at the categories, so you will have to add the non-category terms yourself. You can do this by hooking into the atompub_create_post and atompub_put_post hooks, which get the WordPress post ID and the full entry the client sent, which includes all terms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜