Is it that you want to be able to display the same page in different ways? What would the difference be? And what criteria would you use to determine the way the page appears?
I once created a pair of shortcodes, one that displays text only when the user is logged in, and the other that displays text only when the user is not logged in. On any page I can use the shortcodes to display different text to logged-in users and to other visitors. Is that the kind of thing you need?
Hi, I still have not solved this issue.
Thanks for your response, the different views of the same page is not for when a user is logged in or out, the reason I need two views of the same page is for the print view.
Normal design would be the single-coupon.php design and the single.php is a totally different design, totaly difference CSS for the print view of the page.
Any one have any ideas how I can do this?
Many thanks
Another alternative I have throught of is creating a new page and click on the link to that page to print.
So I have created /print-coupon/ which has its own design and print friendly layout. I have changed my print link so it now go to /print-coupon/ – but the post data and info is not followed through to this page.
Is there away I can get get the post details, from the same ID, to appear on /print-coupon/ page as well?
Many thanks,
Thanks for the link – I have just tested this plugin which redirects posts to have a different layout, but I can’t switch between two layouts.
Is there any way to select the template for the page from the link?? Allowing the_permalink(); to select a different layout for the link?
<a href="<?php the_permalink(); ?>"><?php _e( 'Print Coupon', 'wpcoupon' ) ?></a>
This plugin just enables you to select a template to use on a post as you would on a page.
Do you want to be able to change the layout of the post once someone is looking at it, or is the plan to provide two different links to the same post, one that displays it with one template, and one that uses another?
I would like to provide two different links to the same post, one that displays it with one template, and one that uses another!
Really hope there is a way to do this!
I’ve done something like this before with posts being displayed using a custom post template whenever a certain URL parameter is used in the link.
This article by Stephen Cronin explains one way to achieve this:
http://scratch99.com/wordpress/development/how-to-change-post-template-via-url-parameter/
spanglishwebs, you can create a custom php file to display a post of your choice by hooking into template_include as below:
add_filter('template_include', 'my_template_include');
function my_template_include( $template ){
$url = gidd_current_url();
if ( $url == "http://localhost/demo/print-coupon/" ){
$my_template = get_stylesheet_directory() . '/print_coupon.php';
return $my_template;
}
return $template;
}
Here is the source for getting current url.
Then, in print_coupon.php, you can write a custom query to get the post content as below:
$post_id = 4;
$post = get_post( $post_id );
echo apply_filters('the_content', $post->post_content);
Hope this helps.