Is it possible to have two different previews of a post (ie. two templates for one post)?

I’m looking for a way to allow post editors to see two different previews of the posts they are writing. On the front, the same post can appear it two different sections of the website (each shows a different amount of custom fields). How can I create two preview links (for ex : “Preview with template 1” and “Preview with template 2”) ?

Related posts

Leave a Reply

1 comment

  1. The easiest way to solve this is to create a special template file for previews, that will show the post twice in the different layouts.

    The following code will use the single-preview.php template file if it exists:

    add_filter( 'single_template', 'wpse15770_single_template' );
    function wpse15770_single_template( $templates )
    {
        if ( is_preview() ) {
            $templates = locate_template( array( 'single-preview.php', $templates ) );
        }
        return $templates;
    }
    

    If you want to show the same post twice you must remember to add rewind_posts() in your single-preview.php template file, otherwise you can’t loop over the posts again.