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 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
up vote 0 down vote accepted

Yes it is possible using get_template_part();

Assuming that you use a standard single.php:

 * Template name: template-blog-left

get_header(); ?>

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

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

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

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.