0

I wonder if I can have two single.php templates for different sources.

The problem is:

- I have the full website, with the blog and the home.php that opens posts in the single.php template.

- Then, I have to create a different home.php (without header and footer) to show in a webview inside a mobile app, therefore, I need that the posts should open on a different single.php template, also without header and footer, alongside other features not available on the app version.

The site is responsive, so wp_is_mobile is not an option.

How can I do that?

  • Post your single.php contents and I'll see what I can do for you. :) Pretty sure you can just use the same single.php with some conditional wrapping. – Joel Hager Apr 26 at 2:11
  • Are you able to pass some sort of variable or indicator from the app? This is actually a relatively simple process if we have something we can 'check for'. Even something as simple as the app being classed as a specific type of browser - we're already able to check if a site is on Safari, Chrome, Firefox, IE/Edge, Opera, etc. I regularly do this if I need to have different CSS depending on the browser - so I just chuck the browser identifier into the body tag as a class and write CSS based on that. – Tony Djukic Apr 26 at 17:00
0

You would use page templates to accomplish what you're doing. If you specify a page-{slug}.php, it'll use that one instead. It always does upward traversal. So if there's a specific page, it'll use it. If not, it'll be one level more general.

Copy the home.php PHP into your new one, and remove the calls for the header and footer. Voila!

You could also wrap the calls to the header/footer in an is_page() conditional

if (is_page("slug-name") { get_header() } <- pseudo code for you to get the idea You'll have to see what all you need to wrap in conditionals for your use case.

More info on using Page Templates: here

| improve this answer | |

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.