admin管理员组

文章数量:1122846

Note that this is all within a plugin if it makes a difference.

What I want to achieve...

I have a custom post type defined, with some related taxonomies. I would like to allow site admins to define one or more layouts for it using basic html and shortcodes. I will then allow the end users to select a layout and a taxonomy and will show a page with the layout repeated for each post in the taxonomy. To provide some context, my custom post type represents a recipe, and the admin might want to define one layout showing just the name and the allergens, and another layout showing the name, a thumbnail and full ingredient details. On selecting a taxonomy and layout style, all posts in the taxonomy should be shown to the end user.

I'm not sure of the best way to approach this. My current thinking is that I have a template that manages setting the WP_Query parameters. The admin can then define any number of pages that each represent a layout, as long as they use the template I will include in the plugin. So effectively the page defines the layout for a single post, and when it is selected by the end user I will need that page to loop, repeating itself for each post in the chosen taxonomy. I would then define a new custom post type to represent the layout, where the admin could define a name for it, the associated page and a few other meta fields.

Am I thinking about this the wrong way? Repeating the page for each post feels odd, but I'm not sure how else to give the admins a way to define their layouts.

本文标签: How can I allow plugin users to define layouts for a custom post type