0

I'm back to WordPress development after a long time away from it, and I'm currently writing a plugin for a client that I might find some use to some others. One part of the plugin includes a page template where users have to go.

Now I could style the said page template directly for the client, but it kind of kills the "reusability" factor of it.

I guess my qustion then is: is there a way to ensure a page template have maximum compatibility over all, or no, let's say a maximum, of the themes out there? My guess is no, since all theme developers can do pretty much whatever they can, but maybe one of your have a different opinion.

How would you ensure that a page template is as compatible as possible to a maximum of theme?

  • 1
    You can't. If you need to display something, use something like the_content filter or a Shortcode. – Milo Jul 15 '16 at 3:50
0

This is not possible at all. There aren't even duplication between page templates between the bundled themes.

There is no way for you to know or to predict functions, outlay or markup in any template. IMHO, because of this, templates should always reside within a theme and not in a plugin. Afterall, templates are theme specific and not compatibable cross themes.

Even if it was possible, I would really think that it would be an unmaintainable mess. Introducing new templates in a theme is easy, and it keeps thing maintainable without effort.

As @Milo suggested, there are a couple of filters which you can use to target what is being displayed on a page which includes

  • the_post

  • the_posts

  • loop_start and loop_end

  • post filters like the_content and the_title.

There is also the possibility of using shortcodes which is meant for something like what you want to do

  • Thank you for confirming what I suspected! It's true I didn't think of shortcodes, I'll go that way! – Jean-Philippe Murray Jul 15 '16 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.