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") ?

  • 1
    Adding a second preview button is possible, but it is probably easier to create one preview template that displays the post two times on the same page, but with the two different styles?
    – Jan Fabry
    Apr 27 '11 at 19:00
  • @Jan Fabry: That's a great idea! Is there a way to generate a preview based on a template that is not the one of the current post (because this I cannot change) ?
    – mike23
    Apr 27 '11 at 19:09

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.