I understand templating, and have done a few custom themes in the past. Yet for some reason I'm missing something really basic... help!

  1. Given a specific page (id 427), it renders just fine using the default template (page.php).

  2. I've customized this specific page using (page-427.php). Everything works fine.

  3. ISSUE - I've decided this specific page will use my fullwidth template (page_fullwidth.php), selected in the page editor sidebar, under attributes. When viewing the page, the fullwidth template works as it should (body tag contains page-template-page_fullwidth), however none of my customizations from page-427.php apply!

Where do I put those customizations when the page is already using a custom template?

Right away I think I need a file like "page_fullwidth-427.php" or along those lines, but I haven't got anything to work. I see no documentation on this specifically and not many posts about it.

Ultimately, I'm just injecting custom CSS/JS for that specific page, and it should be injected regardless of the page being default or fullwidth template. Perhaps I should inject it somewhere else, however I have other page-{id}.php's working fine and wanted to keep all page customizations in the same place.

  • If you want to customize page_fullwidth.php, then duplicate that file and name it page-427.php. However, if you're just injecting CSS and JS, you shouldn't be doing that with templates, there are actions for that. – Milo Sep 23 '18 at 1:07

Your Answer

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

Browse other questions tagged or ask your own question.