开发者

How do I set Wordpress Posts to be sub-posts of another Post?

I have X posts about various people. I want to have each person post have a subset of associated posts. Is there any way to do this?

I understand people could be categories, but then I run into a problem of not being able to allow for textual data associated with the people (cate开发者_Go百科gories don't have a post-page equivalent).

Thanks in advance :)


This can't be done with Wordpress posts because their post_parent field cannot be set using the Wordpress admin interface as it can for pages.

However, given that both content types use the same database table and share many fields, it should be possible to write a plugin to allow the post_parent field to be set for posts, you could then retrieve a post's child posts using the get_children function.

You'd need to add a metabox to the post edit page to provide a form for selecting the post parent, and then hook into the save_post action to save the chosen post to the post_parent field. See this example of how to add a metabox and hook into the save_post action: http://codex.wordpress.org/Function_Reference/add_meta_box#Example


Creating these relationships and displaying them on any desired page with a widget or shortcode can be easily done with a plugin called Sub Posts. It's not a free plugin, but it will do exactly what you're asking. You can find more information at www.subposts.com

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜