How to consolidate multiple static page templates into one dynamic one?

I have a group of themes that a client needs consolidated into one. Everything is fairly straight forward, except each theme has theme-specific page templates. Instead of pooling all the template files together in the new master theme, how can I reduce them down to one dynamic template that displays differently depending on a chosen theme option?

When searching myself I came across the template_include filter, which looks like it could be used to override the template that is used, but I’m not sure this is the right solution or how it would be implemented in this case.

Read More

Another idea I have would be to just use conditional includes inside the “master” template.

Any suggestions would be much appreciated.

Related posts

Leave a Reply

1 comment

  1. Personally, I build everything within index.php of each template. I then do conditional checks.

    Example:

    if(is_front_page()){
        // Home page layout
    } elseif(is_page()){
        // General page layout
        if(is_page('contact')){
            // Page layout specific to the contact page
        } elseif(is_page('about')){
            // Page layout specific to the about page
        }
    }
    

    Read more on conditional tags.