How to utilize custom layouts (from the builder) globally for custom post types?
-
Topic
-
So the layout builder has become a very powerful tool, and I love how much time it saves me from coding elaborate html page templates. And I know there’s the “layout to posts” plugin which provides the ability to apply any custom layout to post types other than pages (including my own declared custom post types) — but it’s only available as a metabox selector for each individual post object, meaning you have to go and manually choose a template for every new post you create. There’s no way to say “use this custom template *every time* we’re displaying “mycustomposttype” posts.
From an end-user standpoint, having to choose the template every time you create a new CMS entry for say “movies”, so that those “movie” post types are displayed with “mymovielayout” is an extra step that seems unnecessary (create a new “movie” post, then go and tell wordpress that it needs the “movie” layout :P), and opens the possibility that they could forget to select the layout or pick the wrong one. It’s far more effective to restrict the data entry of the end-user to only certain content elements so they can’t mess up the layout, which you, the site builder, have carefully crafted.
I’d be perfectly happy with a purely code solution, some filter hook that I could include (with all my custom post type declarations) that simply tells jumpstart to connect a particular layout ID with a particular custom post type slug. Maybe could even have two hooks for “single” vs. “archive” views of that custom post type. No more need for handmade template files
single-{post_type}.php
archive-{post_type}.php
in the child theme.
If you were going to support this usage in the themeblvd options UI, I would think it would work to display a list of all the declared post types in a column, and then alongside have a dropdown selector for each one, populated with the currently defined custom templates from the builder.
Another route would be to have an option in the template editor (maybe in that Template Information metabox) to assign that particular layout to be the default template for a particular post type. Then the individual post editor metabox (if shown) would provide the option to override for exceptions, but wouldn’t be required every time.
Basically, there needs to be a more global method of applying these incredibly powerful templates. Right now you can only use them one by one, “per post”, via the post editor metabox.
In doing this, you’d really be unleashing the power of the layout builder to be the main tool for site builders to design their dynamic page layouts, replacing much of the need for hardcoded Template Files.
- You must be logged in to reply to this topic.