Forums

Changing which template is used on-the-fly based on query var (1 post)

  1. dgrundel
    Member
    Posted 4 months ago #

    Hi Everyone,

    I'm putting together a coupon site using a custom post type for my coupons. Each coupon has a nicely formatted page for web viewing, and will also have a "printable" version with lots of stuff removed.

    The object is to have the normal template (call it single.php) load for a URL like mysite.com/coupons/my-awesome-coupon but have an entirely different template load (call it print.php) for a URL like mysite.com/coupons/my-awesome-coupon?print

    Normally, I would just use a print stylesheet for this. However, the client will be using these printable pages to import into MailChimp via URL, so the markup and CSS are going to need to be very different.

    My first thought would be to use a filter on template and swap out single.php for print.php.

    Does that make any sense? Am I on the right track or is there a better solution?

Reply

You must log in to post.

About this Topic