Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

Put Templates in your Template so you can Theme while you Theme!

Olivia Rhye

I heard you like templates!

We were making a site that called several different pages on one page. It also required that the markup be different for different types of pages.

We ran into an issue with both is_page_template(); and get_page_template();. The templates went from root which didn't help our code for both a development server and a product server.

After a meeting where we talked over all our options the group came to a decision. They decided to make me do it.

I wanted to avoid includes and use mainly WordPress functions.

The defining function I used was



if (get_post_meta( get_the_ID(), '_wp_page_template', TRUE ) == "page-templates/full-width.php") {

This would get the page template from site root and not server root. Of course this helps when dealing with different servers and it's always good to root from the site root.

After that I just insert all my markup and do and elseif for the next template. I will look into a way to reference page content from different template files and get back to you. It's a work in progress at the moment.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy