0

I have been teetering back and forth on this question for a while and after a recent battle with TinyMCE, I wanted to get some input.

If I am creating very different pages with unique javascript interactions, css, and markup/content is it best to create a single "blank" base template to use as a canvas with which I can create pages via markup added in TinyMCE or to create several page templates that will only ever be used by single pages?

The naming of "templates" makes me think that semantically this is the wrong approach, and such a feature should be used to create templates to which content can be inserted. My issue comes when I have very complex page content involving nested divs, tables, and custom UI functionality that is botched via TinyMCE and generally difficult to manage and keep under version control.

Is there a better approach--am I missing something that is key here?

  • Custom templates makes this a very manageable situation in that it separates truly unique pages absolutely. You may also find using the WP conditional tags suffice when only specific sections of your pages are unique with major areas that are common between them. Serving up unique header/footer or other page pieces can easily be accomplished by testing if(is_page('pageslug')) { } for example – jdm2112 Oct 14 '14 at 18:37
  • I am using several custom templates currently, but is it a best practice to have a template that will only ever be used for a single page? If a good chunk of the site pages are unique in such a way, I can see my templates being something along the lines of a 1-1 relationship with pages. Is this wrong? – josephndenton Oct 14 '14 at 19:30
  • 'Best practice' is probably more opinion than definitive fact in this instance. The WP Codex does specifically list your use as an intended purpose of page templates. This reference might help. "For more extensive changes, intended for just one specific Page..." – jdm2112 Oct 14 '14 at 20:08
0

I use multiple templates, but also use code for some pages. For example, if I have a site with 3 sections, About, Products, and Research I would create page-about.php, page-products.php and page-research.php. These can be customized as necessary though usually they are simply pulling in unique sidebars which I want to include on all pages within that section. I wouldn't use a unique template for each page, but would create templates that can be used by multiple pages that have similar needs.

The home page of the site is a different story. If I code everything into index.php, then the content can only be modified by editing the template. So I might build some things into the template but also add HTML in the editor. This could include multiple divs and various features. If you use the Tiny MCE Advanced plug-in you can set it so the extra paragraphs and breaks can be seen and removed. Or you can use https://wordpress.org/plugins/wpautop-control/ to turn off autotop for the page. This will keep WP from botching up your code.

0

It depends on the skill level of your final user, but for most of them HTML is hard (and it is hard when you try to achieve specific complex layout even for people with technical knowledg0e), therefor the less your users will have to write HTML the more happy they are likely to be. If you can eliminated the need for understanding HTML by writing templates then that is the way to go even if each template will be used for only one page.

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.