1

I have a multisite network with hundreds of individual location-based sites that use the same theme and display the same type of content.

Occasionally I will need to create or change the template of a page for one site and do so by logging in and out of each subsite to repeat this change across the network.

Is there a better way to do this through the shared theme? Ideally, I would like to learn how to define a set of rules: if page name is equal to "Example", always use the example.php template file and so on.

2

If these pages are using the default page.php template, just create a file called page-{slug}.php. So for example, if each subsite has a page with a slug of 'my-cool-page' you'll create a template file called page-my-cool-page.php, upload it to the active theme, and all of the pages with that slug will automatically use that template. (If it's not a custom-coded theme, be sure to use a child theme so your changes won't be lost.)

If the pages are already using a custom template - i.e. you selected tpl-my-cool-template.php from the template dropdown in the editor - that will override `page-my-cool-page.php' and you will have to update them one by one. But it does not sound like that is the case.

  • Unfortunately yes, they are using custom templates. It seems like I should be able to copy template.php to page-template.php instead? – Morgan Mar 27 '17 at 21:27
  • No, if they're using custom templates that you picked from a dropdown list, that will override files like page-{slug}.php. Anytime you pick from the dropdown list it will be a manual process to change it in the future. – WebElaine Apr 6 '17 at 14:16

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.