Automatic setting of Page Template

  1. sleepyjackson

    Manually setting the page template for each page created is not ideal for content creators.

    It would be better if this could be done automatically based on rules (such as 'set page template X if page parent is Y'.

    Posted: 4 years ago #
  2. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    Looks like there's a plugin: http://wordpress.org/plugins/hierarchical-page-template-redirect-plugin-hptr/

    Is that what you were looking for?

    Posted: 4 years ago #
  3. sleepyjackson

    This is more or less what I'm looking for.

    The one limit on that plugin is that with the inheritance model the parent and the child get the same template. But usually a parent is a landing page and should get a different template. E.g I might want all children of /products/shoes to get the shoes product detail page template but /products/shoes page should a listing page template.

    I also note that plugin hasn't been updated in over 1 year.

    Posted: 4 years ago #
  4. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    Not get super hung up on the updates. Many plugins don't need them, as they're simple.

    Still, anyone can fork the plugin :) that said if you're nesting all your pages, you should look into Custom Post Types instead.

    Posted: 4 years ago #
  5. sleepyjackson

    Custom types would be helpful here in theory but in practice this doesn't really sufficiently solve the problem.

    If you roll your own theme, custom types would be a helpful way to address the problem. But like many people I use an off-the-shelf theme, which drives a lot of its presentation layer through page templates. In this scenario, there's no getting away from page templates, which brings us back to the original problem.

    happy to look at the plugin, but this requirement seems fairly core to me.

    Posted: 4 years ago #
  6. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    Except it's not. In fact, it's fairly unique to your situation.

    You have a very one-off problem, which comes with a one-off solution. CPTs or a child theme, where you can roll your perfect need. Or maybe take that plugin and fork it so 'If parent == foo, set children == bar'

    Posted: 4 years ago #
  7. sleepyjackson

    Hi Mika

    Thanks for your reply.

    I'm not a developer so forking a plugin isn't realistic for me.

    Maybe you're right. Maybe the detail of how this gets implemented isn't exactly as I've described - maybe there's a better implementation that has broader appeal.

    Nonetheless I think the broad requirement is still valid. That is, the ability to let the system - rather than the wordpress editor determine which page template to apply to which pages by some pre-defined configurable rules. This is better content management practice in my view as it doesn't require content-editors (who should be concerned only with content) to make decisions about presentation.

    I recognise CPTs might be one way to do this, but this sems overkill. I have to create a CPT just for this? In that case why have Page Templates at all? What I'm suggesting is merely an extension of what already exists (i.e that pages have page templates and that different pages can have different templates), and seems a great way to get value out of the existing Page post type.

    Creating a CPT to solve every problem doesn't seem optimal to me. Further, as mentioned previously, themes provide lots of different page templates. If I go and create a CPT it's harder for me to use these templates.

    I recognise WordPress core functionality can't cater to niche or edge-case requirements. But my view is what I'm describing here is highly generic, not unique to my situation at all.


    Posted: 4 years ago #
  8. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    If you can narrow down 'criteria' into something simple and reproducible, maybe. But the problem is how broad that is, by it's very nature.

    This is all a huge dependency on your choice organization. Want a lot of pages, nested under one? A CPT is better for speed, and maybe sorting and design. One or two pages on their own? Templates make sense. Heck there's a plugin to apply a template for specific tags and categories.

    The flexibility built into WP makes your 'user designed criteria' hard to have only one solution for. Hence plugins and options.

    ETA, perhaps if you spelled it out with a real world example, it would be more obvious, but right now it's a little vague.

    Posted: 4 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    3 Votes
  • Status

    This idea is under consideration