0

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.

  • 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 . – codepixlabs Aug 28 '13 at 10:07
0

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(); ?>
  • @DanielSarmas, you're welcome – iEmanuele Aug 28 '13 at 10:27

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.