2

Is it possible to have two different blog layouts in the same theme? They would pull the same posts, but have a different layout structure. The only idea I've had is making a couple custom page templates that pull blog posts but have different structure/styles. Is there something simple I am missing?

The reasoning is to have one version of the posts (which are educational) that displays a lot of the excerpt and images in the blog index and then a different version that is more succinct for a review printout.

Thanks.

2
  • Is the second option literally for printing purposes? If so you could use a print stylesheet.
    – Tim Malone
    Commented May 18, 2016 at 3:43
  • Mostly printing, but also for on-screen scroll throughs. I've seen how in some Theme Demos, they will show multiple layouts in the demo. I need to look into how that is happening. That's what I need. Maybe some kind of switch statement. Commented May 18, 2016 at 4:57

2 Answers 2

1

YES! You need 2 custom templates. One for standard view for your visitors and second for your review printout. But you need to create also for that second printout page header and footer manualy and also some functionality. You can't use the same head and footer from other pages. Or you can but you then need to overwrite funcionality what you don't need there or disable.

You need to be there just carefull and be clear what you want there. Is not that complicated but can made a mess on that "special" page. Loop of posts can be the same just with new HTML, JS and CSS in printout page.

1

Supposing you want a button on the page to switch between the views, there are two main approaches:

1 - Attach a javascript onclick action to the button that will add/remove a body class. Then have your style.css handle the ordering and display of the elements on the page. This is the easy one.

2 - Add a link to the same page to the button with a query variable added, so it will look like http:\\www.yoursite.com\your-page?queryvar=something. You will need to register the query_var and filter your template depending on the way it is set. This is the way to go if the templates are supposed to be so different you can't do it with css. For your current purpose it's probably overkill.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.