Support » Plugins » Hacks » redirect to other "view" of same post

  • Resolved Adam


    Suppose a single post (single.php) has an URL
    On this page there is a link which is
    In other words, the same URL but with an added /print/ slug.
    When I click on that link I want to show the same post, but with a different layout (coupon).

    I suppose I need to use template_redirect so what I have so far is this:

    add_action("template_redirect",  "couponRedirect");
    function couponRedirect() {
    	global $wp_query;
    	if ('print' == $wp_query->query_vars['name']) {
          if ($wp_query->is_404) {
             $wp_query->is_404 = false;
          header("HTTP/1.1 200 OK");
          include (TEMPLATEPATH . '/coupon.php');

    But this does not display anything (empty page). Now I am guessing I need to include a query? Can someone point me in the right direction as to how to do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    You might look into the Rewrite API. You basically want to send the query variables of any URL with ‘/print’ to your coupon.php template. Your template then uses these variables to properly reconstruct the original post in a manner suitable for your needs.

    Thanks, I was unaware of this possibility.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘redirect to other "view" of same post’ is closed to new replies.