WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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