Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have two custom page templates ("template-blog-left.php" with the sidebar of the left side, and "template-blog-right.php" with the sidebar on the right side.) but I don't know if there's any way of creating a custom single post template for each of them, so that If I select the "template-blog-left.php" for my "Blog" page, then the single page should have the sidebar on the left.

So, in other words, is it possible to have a custom single page being selected automatically every time I make a post, based on the custom page template that is selected for the "Blog" page.

share|improve this question
    
you said you have "template-blog-left.php template which have sidebar in left, so automatically if you will assign this template to any post it will have a sidebar in left . –  pr1nc3 Aug 28 '13 at 10:07
add comment

1 Answer 1

up vote 0 down vote accepted

Yes it is possible using get_template_part();

Assuming that you use a standard single.php:

<?php
/*
 * Template name: template-blog-left
 *
 */

get_header(); ?>

<div id="left-sidebar">
  <!-- Here your left sidebar -->
</div>

<div id="content">
  <?php 
        //This function will look for single.php file in your theme folder
        get_template_part( 'single' );
   ?>
</div>

<?php get_footer(); ?>
share|improve this answer
    
Thanks a lot :) It worked. –  Daniel Sarmas Aug 28 '13 at 10:25
    
@DanielSarmas, you're welcome –  iEmanuele Aug 28 '13 at 10:27
add comment

Your Answer

 
discard

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.