1

I've currently been using the slug to set the page template, using the normal hierarchy

For example, if I wanted to change the page template for http://www.example.com/about-us, I would edit page-about-us.php

If a client was to go and change the page slug, it would no longer load the correct template.

Would it be better to use the 'custom template' dropdown in the WordPress backend?

What is the best practise as far as this is concerned?

Many thanks

  • It totally depdens on your exact situation and what you want to do. If one of the options would be better than other always and in any situation, why having the two options? If you want a template that can be used several times, use a page template, if you want a specific template for a specific page, use page-slug (or page-id). – cybmeta Mar 20 '15 at 16:12
0

It depends on what you're developing the theme for.

Premium Themes - Themes for the masses.

If you're going to sell or distribute the theme to many people use the template drop down which provides the most flexibility to the user. If they delete the page or rename the slug they can always reassign the template using that drop down.

Custom One-Off Theme - Theme for only 1 client.

That being said, in some instances it may just be easier and more user friendly if you instead limit that option so not to confuse the individual. You could save the static page ID as an option or global variable, whatever your preference is and refer to it when necessary. You could combine the best of both and create a "Theme Options" page which allows the user to choose which page they want for a specific feature, then save the page ID; similar to assigning Front-Page or Blog ( WP Settings -> Reading ).


There's been times when I've used option 2 but in most cases the page template drop down suffices and is probably most preferable.

  • Thanks for the feedback. I have decided to add templates to the backend dropdown, with a suitable default. If the user becomes confused by the choice, we can always hide this section of the screen. – Ryan Palmer Mar 23 '15 at 16:01
0

I think custom templates is the best decision for your example. Besides custom page template is easy to develop.

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.