• Hi all. I need to create an alternate view of the standard post page, single.php, with a slightly different set of content. It needs to exist in parallel to the standard version (we’re using them both).

    I’ve created the new php for this purpose, but I don’t know how to reference it such that the post content is applied. Basically, I want something like the print page. I’m happy to hack PHP files.

    Thanks in advance,
    Andrew

Viewing 6 replies - 1 through 6 (of 6 total)
  • Unique Single template
    Suppose you want to use different Single template to display individual post in certain category. You can use the in_category to check what category is the post stored in and then use different Single template. In your default single.php, enter the code below. If the post is in category 1, use single1.php, elseif in category 2, use single2.php, otherwise use single_other.php.

    <?php $post = $wp_query->post;
      if ( in_category('1') ) {
      include(TEMPLATEPATH . '/single1.php');
      } elseif ( in_category('2') ) {
      include(TEMPLATEPATH . '/single2.php');
      } else {
      include(TEMPLATEPATH . '/single_other.php');
      } ?>

    1) You must use category ID codes that exist on your site
    2) In the code example, single_other.php becomes the default sidebar.
    3) To set this up, rename your theme’s file single.php to the name of the new default file – in the example that is single_other.php (use whatever name you prefer).
    4) Make a new file in your theme folder called single.php – paste the code I posted in that new file. that is the only thing that should be in the new single.php.
    5) Make new files single1.php, single2.php, single3.php, setting them up however you wish as custom single templates.
    Give them whatever file name you want. Just change the name of the file for that category in the IF statement I posted to match the actual filename you give the file.

    Thread Starter alienintheheights

    (@alienintheheights)

    Thanks, but I’m looking for a way to have two views of the same post, for all categories. It seems analogous to how the print page works: a pared down template showing the same content.

    Something like this:

    single.php -> standard view for all posts
    custom_single.php -> alt view for all posts

    Perhaps I can detect a query parameter that I’ll add to the link for the alt view, then follow the pattern used above?

    yes, you could do something along that line (query parameter)

    Anyone??? ??

    Thanks!

    something?

    I’m lookin forward to find the answer.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Alternatve view of a single.php post page?’ is closed to new replies.