redirect to other "view" of same post
-
Suppose a single post (single.php) has an URL example.com/post-x/
On this page there is a link which is example.com/post-x/print/
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'); exit; } }
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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘redirect to other "view" of same post’ is closed to new replies.