Home > programming, Techie > Add a Custom Page Template to WordPress Thesis Theme

Add a Custom Page Template to WordPress Thesis Theme

Thesis is a popular premium WordPress theme. Unlike many themes that are implemented to plug directly into the WordPress-defined template structure, Thesis is a force unto itself. It’s a framework that completely redefines the approach to WordPress customization. It achieves this by supplying a rich set of hooks into the various stages of the page generation process and then creates one location where all customization code goes. One file – custom_functions.php – holds all the custom code and is safe from overwriting during theme upgrades.

The Thesis framework is sufficient for a wide range of customization needs. However, as with all popular software, users’ needs eventually go beyond the default capabilities of the software. Thesis has in-built support for creating 2-column and 3-column sites. The layouts are configured via the Design Options menu and apply site-wide. You can override the layout of particular pages (eg home page) by intercepting the page generation process in custom_functions.php. The problem with this approach is that you have to know the designation (home), name or id of the page before-hand as you customize the site. If these details change after the site has been launched, then the customization code is going to break.

Page Template List

Page Template List

What if you want to alter the layout of an arbitrary number of pages that are going to be created in the future? All you know at customization time is what the layout shall be, but not which particular pages shall use it. This obviously calls for a solution that does not involve updating the customization code every time a page requires the custom layout. Even better, it calls for a facility that can be triggered while the page is being created by the user. A facility such as the WordPress  page Template selection drop-down. If you could create a custom template and have it selectable on the Template drop-down, then the user would simply pick it during page creation (or editing) and have it used for page rendering.

Thesis (version 1.6) does not support plugging in of custom template files, but it is flexible enough to pick them up if you know where to tweak. Here’s how you go about doing exactly that:

1)       Problem description

The hypothetical site we shall be working with is a travel blog. The site has various sections, but the one that is of interest here is one called Places. It has pages describing various travel destinations. These pages have advertising that shows in the left column. Every other type of page on the site does not have this left column and therefore no ads showing. How do we get the ads to show on the Places pages, but not on any other page?

2)       Create the page template file

The Thesis theme has a convention, where customization code is stored in the /wp-content/themes/thesis/custom/ folder. The standard customization files in this folder are custom_functions.php and custom.css for code and styling respectively. This is the folder where you shall put the new custom template file places_template_functions.php. The code for the template file is:

	remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
	add_action('thesis_hook_custom_template', 'places_page_layout');
	function places_page_layout () {
		if (is_page()) {
			global $post;
			$places_template = get_post_meta($post->ID, '_places_template_swapped', true);
					<div id="places_page_content">
						<div id="sidebars">
							<?php places_ad_column(); ?>
						<?php thesis_content_column(); ?>
					<?php thesis_sidebars(); ?>
	register_sidebar(array('name'=>'Places Ads', 'before_title'=>'<h3>', 'after_title'=>'</h3>'));
	function places_ad_column(){
		<ul class="sidebar_list">
			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Places Ads') ){ ?>
				<li class="widget">Place ads here</li>
			<?php } ?>
	<?php }

The function places_page_layout () confirms that the current page is using the Places Template and then inserts the ad column into the page by calling places_ad_column().

3)       Create the template placeholder file

The placeholder file has two roles:

i)                     Register the new custom template in WordPress

ii)                   Call on Thesis framework to generate the Places page

The place holder file shall be located in the folder /wp-content/themes/thesis/ and called places_template.php. The code for the file is:

	 * Template Name: Places Template
	 * A custom template for use with Thesis theme for creating pages that add a left sidebar.
	 *  DO NOT EDIT THIS FILE. Instead, use the thesis_hook_custom_template() hook in custom/places_template_functions.php
	 * @package Thesis



The text Template Name: Places Template is key since it informs WordPress what the new template is called. The template is now listed in the WordPress page editor.

New Template Listed

New Template Listed

4)       Load the new template into Thesis

The files that are in place so far enable WordPress to list the new template in the page Template drop-down. However, the template code is inaccessible since has not been loaded. The loading of the template code is accomplished by piggy-backing onto the Thesis custom_functions.php file. Add the following code to the end of the file:

if (file_exists(THESIS_CUSTOM . '/places_template_functions.php')){
	include(THESIS_CUSTOM . '/places_template_functions.php');

5)       Override Thesis custom template handling

Thesis is not aware of the new template and therefore cannot invoke it when a Places page is opened. To remedy this, we have to add code to the file places_template_functions.php that intercepts Thesis page generation and directs it execute the new template. Add the following code to the end of places_template_functions.php before the lalst  ?> :

/* Get Thesis to invoke this template*/
 if ( !is_admin() ) {
	add_action('thesis_hook_before_content_area', 'places_page_template_swap_before_content');
	add_action('thesis_hook_after_content_area', 'places_page_template_swap_after_content');

function places_page_template_swap_before_content(){
	if (is_page()) {
		global $post;
		global $swapped_post;
		$page_template = get_post_meta($post->ID, '_wp_page_template', true);
		if($page_template == 'places_template.php'){
			update_post_meta($post->ID, '_wp_page_template', 'custom_template.php');
			$swap_id = time();
			update_post_meta($post->ID, '_places_template_swapped', $swap_id);
			$swapped_post = $post;
			$template_swapped = get_post_meta($post->ID, '_places_template_swapped', true);
				$swapped_post = $post;

function places_page_template_swap_after_content(){
	if (is_page()) {
		global $swapped_post;
		if(isset($swapped_post) && is_object($swapped_post)){
			$template_swapped = get_post_meta($swapped_post->ID, '_places_template_swapped', true);
				$page_template = get_post_meta($swapped_post->ID, '_wp_page_template', true);
				if($page_template == 'custom_template.php'){
					update_post_meta($swapped_post->ID, '_wp_page_template', 'places_template.php');
				delete_post_meta($swapped_post->ID, '_places_template_swapped');

You are now able to create a page, assign it the Places Template and view it to see the Places Ads column. Putting in the actual ad content can be done in the WordPress Widgets screen (Appearance > Widgets) by placing a suitable widget onto the Places Ads sidebar.

Palces Sidebar

Palces Sidebar

6)       Positioning the Places Ads column

Since you have taken over the task of laying out the page columns, you’ll find that Thesis does not position the new column automatically. You need to add CSS to handle this. In this case, adding the following code to custom.css does the trick:

/* Ad column */
div#places_page_content {
	width: 656px;
	float: left;
div#places_page_content div#content {
	width: 545px;
	float: right;
div#places_page_content div#sidebars {
	width: 95px;
	float: left;
/* @end */
Places Template in action

Places Template in action


Some people who have tried the code in this tutorial report that everything works ok, but the new column doesn’t show up. The most likely cause for this is that the hook that allows Thesis to see your template is not getting called. The hook to apply is dependent on the framework (Thesis Options > Design Options > Framework Options) that you’re using for the site:

1. If you’re using the ‘Full-width framework’ then the hook used in the tutorial is the correct one: thesis_hook_before_content_area

2. For ‘Page framework’, the correct hook is thesis_hook_before_content_box so edit the code in places_template_functions.php to replace:

thesis_hook_before_content_area with thesis_hook_before_content_box

thesis_hook_after_content_area with thesis_hook_after_content_box

remove_action(‘thesis_hook_custom_template’, ‘thesis_custom_template_sample’);

Thesis 1.8 Note:

Thanks to Cannolo (in the comments) who allowed me access to his server, I was able to debug a peculiar problem that was afflicting some implementations of the Places custom template. It turns out that in Thesis 1.8, the call to the thesis_hook_before_content_box hook was repositioned. The consequence of this is that the template swap performed by the hook now happens too late to be of any effect. The next available hook in the chain is thesis_hook_before_html. Therefore, for those who chose to use the ‘Page framework’, apply the following modification to your code:

Edit the code in places_template_functions.php to replace:

thesis_hook_before_content_area with thesis_hook_before_html

thesis_hook_after_content_area with thesis_hook_after_html

remove_action(‘thesis_hook_custom_template’, ‘thesis_custom_template_sample’);
Categories: programming, Techie Tags: , ,
  1. June 6, 2010 at 18:09

    Does this work in Thesis 1.7? Is it still necessary? Seems like a lot of work.

    Thanks for contributing this.

    • kalengi
      June 6, 2010 at 20:18

      Hi Pierre,

      It IS a lot of work compared to the usual way in which page customization is done in Thesis. It’s meant to handle cases where you want a group of pages to use a different page structure from the rest of the site. The custom_functions.php route works if 1) you know the names/ids of the pages before hand and 2) you don’t mind hard-coding a large number of page ids if the pages you’re working with are more than just a handful. This method saves you having to know what pages are using the template.

      The technique still works with Thesis 1.7


      • October 24, 2010 at 09:05

        I loathe hard coding page information. I loathe even using conditional statements! These sorts of layouts really lend themselves to a functional approach, and it’s just painful to dig through various files where the same conditions are checked over and over again. I’m talking to you, ‘invert’.

        Anyways, this is a good technique, and it adds to my arsenal.

        • kalengi
          October 24, 2010 at 13:49

          Hi David,

          You’re so right about ‘invert’! Hard coding is prevalent in the world of WordPress customization. People get away with it since there’s normally not much of a penalty. However, as you’ve said, it’s something I try to avoid whenever I can.

          Thanks for appreciating 🙂

          PS: What technique are you using with the Thesis functions?

          • November 20, 2011 at 10:04

            A couple of years ago, I built myself a framework for really fast templating with Thesis. What I do is isolate tease apart the Thesis logic, and create functions which handle arranging the hooks directly. In some sense, it’s a longer way around the block. In another sense, assembling a new template is like snapping legos together, no conditionals at all. Sidebars and css can be passed in, a little more work gets custom headers as well. Ping me any time.

          • kalengi
            November 20, 2011 at 11:24

            Hey David,

            Nice to hear from you again! Interesting that you chose now to send me this when I was thinking that plugin and framework creators typically skip the part about making their products extensible and interoperable (I think it’s a word) with random code out in the wild. For example, the BuddyPress Extended Profile Fields framework has no easy way to add new field types. I’m in the middle of hacking together a solution to add an image field type while ensuring I do not edit core files. Doing this kind of stuff should be exactly like you phrased it – Snapping legos together 🙂

          • November 21, 2011 at 07:13

            kalengi :
            Hey David,
            Nice to hear from you again! […] Doing this kind of stuff should be exactly like you phrased it – Snapping legos together

            Thanks Alex.

            I’ve found that having test harness in place allows much faster refactoring for API development. Without a test harness, it’s white-knuckle all the way.

  2. June 6, 2010 at 18:11

    Forgot to set the “Notify me” option.

  3. Chuck
    June 8, 2010 at 14:56

    I’m a bit confused by the last part. Why do you have to “swap” the template before and after the content hooks? Why not just override the template with the first hook?

    Can you explain that a little bit more so I can understand what’s going on? Thanks!

    • kalengi
      June 8, 2010 at 21:37

      Hi Chuck,

      The template name swap is necessary because of the way Thesis works. When Thesis is generating a page, it checks the template name assigned to the page. It knows about the two in-built templates: no_sidebars.php and custom_template.php. If the template name does not match these then it is assumed that the page is using the Default Template and therefore any hooks you may have set up are not called.

      Since the custom template file that we’ve set up is going to be ignored by Thesis, we have to change the stored template name to one that Thesis knows (custom_template.php) so the custom code can be executed. The line update_post_meta($post->ID, '_wp_page_template', 'custom_template.php'); does this. Once the template has been processed, we need to change the stored name back to the original so that the page author sees it selected on the Template drop down list. The line update_post_meta($swapped_post->ID, '_wp_page_template', 'places_template.php'); handles that.

      Hope this helps 🙂

      • Chuck
        June 9, 2010 at 13:26

        Thanks. That does help explain alot.

  4. Seth
    June 15, 2010 at 05:51

    Thank you very much for writing this code. I am having a few problems implementing it though. When I pasted the it in I get this error message:

    Warning: Cannot modify header information – headers already sent by (output started at *****/thesis_17/custom/places_template_functions.php:2) in *****/wp-includes/pluggable.php on line 868

    I would greatly appreciate any advise.

    • kalengi
      June 15, 2010 at 08:19

      Hi Seth, great to know that you found the code useful 🙂 From your description, it sounds like the error has been caused by some space before the opening <?php directive in the source file. Make sure that nothing precedes the <?php directive.

      • Seth
        June 15, 2010 at 18:49

        Thanks, getting rid of the space fixed it. I got the sidebar showing on the page 🙂 but there two copies of the page contents. Do you have any ideas what might be happening?

        • kalengi
          June 15, 2010 at 20:07

          Great! Now this other one is harder to determine without some more detail. Do you have a screenshot or link to the page?

          • Seth
            June 15, 2010 at 20:43

            Sure. Thanks for your help.

          • Seth
            June 15, 2010 at 21:11

            Sorry, I guess html is not accepted. Here is the url to a screenshot.

          • kalengi
            June 17, 2010 at 03:56

            In case some else encounters the same issue, removing the line thesis_content_column(); sorted it out.

  5. June 16, 2010 at 10:24

    Great post.I am spending more than 15 hours to getting a little spark to solve this same issue.At last I am near you.Thank you so much.

    I think all configurations are completed.Unfortunately due to my limited knowledge which is not displaying our(places_ad_column) side bar.Which showing all other sidebar(sidebar1 and 2).What may be the problem.

    Can you please give me any idea? Thanks!

    • kalengi
      June 16, 2010 at 12:33

      Hi Ajith, if you list the steps you’ve gone through in getting the template to work, I’ll be in a better position to spot what’s amiss. Thanks!

  6. Luke
    June 19, 2010 at 23:57


    This is an excellent tutorial! I was wondering what effects will this have on upgrading to the next Thesis version? Aren’t you editing core files in the above example?


    • kalengi
      June 20, 2010 at 14:47

      Hi Luke,

      Actually one of the key things I was aiming at was to avoid touching any Thesis core files so as to ease upgrades. Once you have followed the steps and put the template in place, you’ll have all the code in files that Thesis does not touch during upgrades.


  7. JC
    July 1, 2010 at 03:25

    Hey great tutorial, really helpful. The thing I’m trying to do is almost exactly what you have done here with this (even down to a template for places). The only thing that’s different is that I’d like to be able to have the places template keep one sidebar on the right hand side so that I could just put my ads in with a widget instead (seems easier to me).

    This may be above and beyond here, but how might I do this template while preserving a right-hand sidebar?


    • kalengi
      July 1, 2010 at 04:23

      Thanks JC 🙂 I’m not sure the situation you’re describing requires this level of customization. If you want the ads to appear on the right sidebar on all pages, then it’s much easier to place the ad widget onto a standard Thesis sidebar. Thesis displays it’s standard sidebars on the right by default.

  8. JC
    July 1, 2010 at 05:16

    Well I’d like to develop a fairly sophisticated template in the end, but I want to build it on the basic platform of having one main content area with just one right-hand sidebar. Currently Thesis doesn’t offer “one sidebar” templates that I’m aware of, just the default and “no sidebar” options.

    I guess I’ll probably be best served by creating a custom “one sidebar” template and then building what I need on top of that.

    • kalengi
      July 1, 2010 at 18:09

      Oh, I see what you’re after. You can do that in Thesis by going to Thesis Options > Design Options > Site Layout. There you can select the 2-column layout under ‘Columns’ and then specify Content, Sidebar 1 arrangement under ‘Column Order’. That would give you a main content area with one right-hand sidebar throughout the site.

      Is that what you’re describing?

  9. JC
    July 1, 2010 at 18:12

    Sort of. I don’t want one sort of template site-wide though, rather the option of selecting a one-sidebar, default two sidebar, or no sidebar layout for each specific page. For the main blog page, for example, I want the standard two-sidebar layout. But I’ll also have some pages that are more static in nature, where I’d really like to be able to do a custom layout based on a one-sidebar platform. I hope that makes some sense?

    I’ll poke around a bit more about ideas with this, but if you can think of anything let me know. I’m sure I’m not the only one with this need!

    • kalengi
      July 1, 2010 at 18:45

      In order to get just two columns on the custom template, you can leave out the line in places_template_functions.php. The sidebar is placed on the right by default. The one in the example appears on the left due to some additional css.

  10. July 1, 2010 at 19:43

    Instead of “Great Work! Can you help me with…” 🙂 I’m just going to say


    • kalengi
      July 1, 2010 at 20:31

      Thanks! 🙂

  11. August 2, 2010 at 05:42


    Been trying to get custom pages to work in Thesis for months… and I was really excited about this tutorial because it looks like it should work, but alas, I cant get it to read the custom template. I think I did everything right. The functions file goes in thesis/custom. Template file goes in the main thesis folder. I copied and uploaded custom_functions.php and custom.css to their right place. The template is showing in the dropdown on the page and the new sidebar widgets are showing in admin. For some reason, its not reading the template. http://drlab.digitalrenewal.com/thesis

    Seems like everyone else is getting it wroking… Any Idea what I might be doing wrong? Has anything changed in the last month in thesis? I have version 1.7

    Thanks so much!

    • kalengi
      August 2, 2010 at 13:36

      Hi Trisha,

      Looking at the link that you posted, it seems the custom page handling is not being triggered. The page displayed is using the Default Template selection. Edit the Places page (id=4), select Places Template on the Template drop-down and then click on Update to save. With this done, the template should be called when the Places page is loaded.

      Thanks for appreciating the tutorial 🙂

      • August 2, 2010 at 16:53

        Thats why I was so confused… the Places template IS selected from the drop-down.

        It’s a great tutorial! Very well explained, and of all the ones I’ve tried, this seems like the best way to do it.

        • kalengi
          August 2, 2010 at 20:30

          Send me your code on mail. I’m sure the answer’s in there somewhere.

  12. Anjani
    August 18, 2010 at 00:00

    Very helpful post. I just created a new template and it is working fine, but I am getting some problem, I don’t want any default sidebar in my new template. how can I fix this problem. It will be great help.

    • kalengi
      August 18, 2010 at 11:04

      Hello Anjani,

      The default sidebars can be omitted by removing the code thesis_content_column(); from places_template_functions.php

      Thanks 🙂

    • kalengi
      August 18, 2010 at 21:53

      oops! @Anjani I accidentally copied the wrong line of code. The line that controls the default side-bars is thesis_sidebars();. That’s the one you should remove. Sorry about the mix-up.

  13. kate
    August 18, 2010 at 23:52

    This is so great! Thanks a million!

    • kalengi
      August 19, 2010 at 12:23

      You’re most welcome @kate 🙂

      • waaahoo
        August 22, 2010 at 05:10

        Hey Kalengi,

        thanks for sharing your knowledge.

        When creating a page I’d like the ability to designate it as either:

        a. 3 column 2 sidebar on the right.
        b. 2 column 1 sidebar on the right.
        c. 1 column no sidebar.

        From what I gather this means I would have to create 3 different custom templates using your method. Chances of me doing this without blacking out the eastern seaboard are currently 0%.

        If you would be interested in talking/typing me through the process I would be interested in paying you to do so.

        Let me know.

        • kalengi
          August 22, 2010 at 18:10

          Hi waaahoo! Sure thing, I’ll get in touch on mail.

          Thanks 🙂

  14. Anjani
    August 22, 2010 at 14:01

    Thanks for your reply!!!

    I removed the thesis_sidebars(); from places_template_functions.php.But it is showing those side bars.Don’t know how can i get rid of this.Please help me on this.


    • kalengi
      August 22, 2010 at 18:50

      @Anjani: Sounds like there’s some other custom code in custom_functions.php that is activating sidebars on pages.

  15. Anjani
    August 22, 2010 at 21:04

    Hi kalengi 🙂

    Really appreciate your quick response.Thanks a lot Sir!!!!
    So what should i do now to remove sidebar from this page….
    Please help me!!!!


    • kalengi
      August 22, 2010 at 23:48

      Sure @Anjani, let’s have a look at your custom code. I’ll get in touch on mail.

      • Anjani
        August 23, 2010 at 01:43

        Thanks for your quick response!!!
        yes there is some custom code and widgets which has been used here.So how can i remove these at this template.I don’t want these at my new template like no_sidebars

        • kalengi
          August 23, 2010 at 03:47

          @Anjani – I sent you mail on your registered address.

  16. August 23, 2010 at 07:16

    Thanks for sharing this, it is just what I have been looking for. I can’t get it to work though. I would be very grateful for some help. In wp-admin everything seems okay. I have the template in the drop down list and have applied it to a page called France. The places sidebar shows up on the widgets page, and I’ve put some widgets on it. On my France page, the column doesn’t show up, and I can’t see the reference to the places_template.php in the pages source code. I’m using thesis 1.7.

    • kalengi
      August 23, 2010 at 19:48

      Hi Carmel,

      I’ll do a quick check on Thesis 1.7 and then get back to you.

      Thanks for appreciating 🙂

      • August 24, 2010 at 07:48

        might it be because the themes folder is thesis_17? This might mean that codes for other versions wouldn’t not work here if this folder name is in the code.

        • kalengi
          August 24, 2010 at 15:53

          @Carmel: I’ve confirmed that Thesis 1.7 is not the cause. I think the most likely mis-step is naming the custom template file something other than places_template_functions.php . It’s important that the file name matches exactly.

          • August 26, 2010 at 16:04

            these file names are right.

  17. August 23, 2010 at 07:17

    The page I have tried to modify is http://carmeljames.com/myblog/?page_id=100

  18. kalengi
    August 26, 2010 at 20:54

    Hey Carmel,

    I think Thesis is the culprit after all 🙂 Since Thesis started appending the theme version to the folder name, it’s tempting to upgrade by copying the thesis_17 folder into the /wp-content/themes folder while the previous thesis folder (perhaps thesis_16) is still in place. The end result is a corrupted upgrade.

    You may not notice any problems until the moment you decide to create a custom template. Everything about the Places Template is OK, but WordPress cannot find it since Thesis 1.7 is not registered properly. One way to sort this out is:

    1) Make sure you have only one copy of Thesis (thesis_17 in your case) in the themes folder by deleting any other copies apart from the one you’re using.
    2) Visit Appearance > Themes page to activate Thesis. It is likely that you’ll find no selected theme.

    That should sort out the problem. Let me know how it goes.


  19. August 27, 2010 at 11:35

    I didn’t upgrade, I jumped right in at version 1.7.
    I definitely have thesis running, been using other features.

    • kalengi
      August 27, 2010 at 15:59

      Here’s another likely cause. If you’re using the ‘Page framework’ layout of Thesis, then the action hook to trigger the template code does not work. In order for the template to work, select ‘Full-width framework’ on the ‘Thesis Options’ > ‘Design Options’ > ‘Framework Options’ section. For a thorough explanation of the difference between ‘Page framework’ and ‘Full-width framework’, see this video turorial by Kristarella.

      If you want to keep the ‘Page framework’ setting, then make the following changes to the template code in places_template_functions.php:
      1) Replace thesis_hook_before_content_area with thesis_hook_before_content_box
      2) Replace thesis_hook_after_content_area with thesis_hook_after_content_box

  20. August 27, 2010 at 16:16

    sadly, I’m am already using the full-width framework.
    I really appreciate you spending time thinking about this.
    I can’t help feeling I’ve done something wrong, but I checked it yet again today, and I can’t find any mistakes.
    I am however very limited by the “Fatal error: Allowed memory size … ” that seems to be very common. I’ve tried everything but I can’t even upload pictures now without that error popping up. I’m waiting to hear from the people hosting my site. If I can fix that, maybe this will work, though it’s hard to imagine memory is preventing it from happening.
    I will look at other options that I’ve changed and see what happens.

  21. September 15, 2010 at 15:16


    Really appreciate the tutorial as it provided an easier solution than the one I was originally trying.

    The only problem I have are the default sidebars are showing, which I don’t want. I’ve removed the line ‘thesis_sidebars();’ from the template file and cleared out my custom_functions.php file apart from the entries to load the template into Thesis but they still show up.

    Any suggestions as to where else I should look? I’m using Thesis 1.7 (new install).


    • kalengi
      September 15, 2010 at 16:02

      Hi Byron,

      Is the custom sidebar showing? What is the url to the page having the custom sidebar?


  22. Wendy
    September 17, 2010 at 09:39

    First, thanks so much for such a great tutorial. I’m nearly there.

    I’m using 1.7 (no previous versions) and following the directions, it still wasn’t pulling up the new template.

    I did some troubleshooting and found that unless I pick “custom template”, the add_action(‘thesis_hook_custom_template’, ‘places_page_layout’); doesn’t fire.

    If I switch the template to custom (in the WP template drop down), then it fires.

    So what am I missing? I copied the custom_template.php and renamed it, then changed the template name in the comments. Otherwise it’s the same.

    Thanks for any additional help.

    • kalengi
      September 17, 2010 at 13:13

      Hi Wendy,

      Sounds like you may be facing the problem I described to @Carmel in this comment. See if it sorts out your issue.

      Hope you get there 🙂

  23. Wendy
    September 17, 2010 at 17:01

    No – I saw that and did that. And it did fix a problem. After that was when it started working if I selected the custom template. It just won’t fire the “thesis_hook_custom_template” if I don’t pick custom template in the drop down. Which seems very weird to me because both template files have the same line of code in them, shouldn’t they do the same thing?

    • kalengi
      September 17, 2010 at 22:48

      I think my mental model of your setup is broken 🙂 I require some more detail so I can have better context and perhaps spot the problem.

  24. October 24, 2010 at 09:02

    That’s pretty slick. I’m doing it slightly differently, using the Thesis functions as built-in “bricks” to set up a variety of page types. It was easier in 1.6. The control of flow in 1.8 seems more difficult to get a grip. If I didn’t want arbitrary sidebars, it would be pretty easy though.

  25. October 26, 2010 at 00:33

    Try —

    remove_action(‘thesis_hook_custom_template’, ‘thesis_custom_template_sample’);
    add_action(‘thesis_hook_custom_template’, ‘places_page_layout’);

    You must ‘remove’ it first then add it 😉


    • kalengi
      October 26, 2010 at 02:58

      Hi asoel,

      Thanks for pointing that out! I’ve updated the code.

  26. November 19, 2010 at 04:18

    customizing a customize theme..hmm is there anything yet complicated than this?

    • kalengi
      November 19, 2010 at 11:26

      There’s no end to customizing 🙂

  27. owen
    January 10, 2011 at 13:35

    Pls kalengi help me i don’t know how to add your function in Thesis.


    • kalengi
      January 10, 2011 at 13:42

      Hi Owen,

      Please describe the steps you’ve taken so far so I can see how to help.


      • owen
        January 10, 2011 at 14:04

        what is step1 to do and next step to do


        for example
        step 01 is create “places_template_functions.php” /wp-content/themes/thesis/custom

      • owen
        January 10, 2011 at 15:38

        Hi Kalengi,

        how to create “Register the new custom template in WordPress”

        thanks so much

        • owen
          January 10, 2011 at 19:46

          thanks kalengi right now is working on my own wordpress website.

  28. February 10, 2011 at 00:14

    this page


    doesnt seem to exist in thesis 1.8, so how do I proceed?

    what Im trying to do is make my post pages sidebar 1 free…so this gets me a pice of the way there….




    • kalengi
      February 10, 2011 at 02:08

      Hey Larry,

      The file places_template_functions.php doesn’t belong to Thesis. You create it as described in step 2) in the same location as custom_functions.php

      Hope this helps! 🙂

  29. February 13, 2011 at 04:57

    Hi Kalengi,

    Thanks for the great introduction to Thesis and its hooks. You have provided the easiest to understand version, by far 😀

    I’m running on Thesis 1.8 and I styled my “About” page using the “no sidebars” attribute. I left it there for a while to do some work and recently returned to revert back to the regular template only to find that the “template” feature is now missing!

    Does your code function to retrieve missing features like this? Will really appreciate your help here.

    • kalengi
      February 14, 2011 at 17:49

      Hi Christine!

      Thanks for your appreciation 🙂

      Do you mean that the ‘Templates’ drop-down is missing from the page editing screen?

  30. February 14, 2011 at 18:16

    Hi Kalengi – Yes, the “template” feature is missing. The only features I have are “Parent” (also missing the drop-down menu) and “Order”. It’s really weird as I don’t experience this with my other blogs. Thanks for responding.

    • kalengi
      February 14, 2011 at 19:17

      The ‘Template’ drop-down disappears if your theme has no templates to select from. Since you’re using Thesis, there’s always at least two templates: Custom Template and No Sidebars. The only reason I can think of that these templates aren’t listing is there’s another version of Thesis present in the themes folder. For example, if you still have Thesis 1.7 (thesis_17) folder in your themes folder, it could interfere with the loading of the Template list. In this case the solution is to remove the older Thesis folder and leave just the version you’re currently using.

      Hope that helps!

  31. February 15, 2011 at 20:48

    Hey, just wanted to comment to confirm this still works with thesis 1.8 also as I have just implemented it. Thanks for this approach Alex, its so much more user friendly. I have used this and instead of pulling a custom sidebar in, I am calling custom meta content for a 1 sidebar template and 2 sidebar template using multiple wysiwyg;s on the edit page screen. I am using wpalchemy which you can see here…



    Might be useful to someone else.

    • kalengi
      February 16, 2011 at 02:17

      Thanks very much David! It’s definitely helpful to confirm compatibility with Thesis 1.8 and even better to know that this tutorial has helped you 🙂

  32. March 2, 2011 at 20:35

    your tutorial is awesome….execept: as you can see if you to my page, i am getting that block of code at the top and i’m not sure why. any ideas would be great. thanks.

    • kalengi
      March 3, 2011 at 23:23

      Hi Niki,

      Thanks for the appreciation 🙂 What code are you referring to?

      • March 3, 2011 at 23:34

        oh shoot…i removed everything because it was driving me nuts….

        its this chunk:

        /* Get Thesis to invoke this template*/
        if ( !is_admin() ) {
        add_action('thesis_hook_before_content_area', 'places_page_template_swap_before_content');
        add_action('thesis_hook_after_content_area', 'places_page_template_swap_after_content');

        function places_page_template_swap_before_content(){
        if (is_page()) {
        global $post;
        global $swapped_post;

        $page_template = get_post_meta($post->ID, '_wp_page_template', true);
        if($page_template == 'places_template.php'){
        update_post_meta($post->ID, '_wp_page_template', 'custom_template.php');
        $swap_id = time();
        update_post_meta($post->ID, '_places_template_swapped', $swap_id);
        $swapped_post = $post;

        $template_swapped = get_post_meta($post->ID, '_places_template_swapped', true);
        $swapped_post = $post;

        that appeared at the top of my page….also at the top of my admin dashboard.

    • kalengi
      March 3, 2011 at 23:50

      I see… Would you mind putting it back in so I can see how it looks?

      • March 3, 2011 at 23:59

        hmm….put it all back and now seems to be working just fine. thank you very. one question…if I want to edit the template, say with the same red heading text on each page that uses that template…where would i make that change?

        • kalengi
          March 4, 2011 at 00:11

          Great! Then that issue’s sorted.

          The per-page heading would go just before the line <div id="places_page_content"> This would place it above the page content.

          • March 4, 2011 at 00:12

            Ok…in which file?

    • kalengi
      March 4, 2011 at 00:18

      That’s in the file places_template_functions.php

      • March 4, 2011 at 00:28

        ahh i feel so stupid…body {color: black;}
        h1 {color: red;}

        put that in but nothing changed

    • kalengi
      March 4, 2011 at 00:37

      What page are you expecting to see the change on?

      • niki mosier
        March 4, 2011 at 01:31

        on the “about” page

        the “hi” text

        • kalengi
          March 4, 2011 at 18:17

          This is somewhat off-topic, but the custom formating in Thesis should go in custom.css as indicated in the tutorial.

  33. March 11, 2011 at 18:41

    Hi, I removed the because I don’t want the sidebars to appear, but they still do. Any other suggestions?

    • kalengi
      March 12, 2011 at 15:11

      Hi Niki 🙂 You removed what, custom.css?

      • March 14, 2011 at 20:04

        I removed the from the file but am stilling get normal side bars on the page, which I dont want. Any suggestions?

        • March 14, 2011 at 21:02

          it keeps taking the code out of my response. i removed the side bar div out of the functions file but they sill show up

          • kalengi
            March 14, 2011 at 23:07

            @Niki If there’s some way I can have a look at the file then let me know through the form on the blog’s sidebar…

  34. March 12, 2011 at 01:57

    I’ve done everything to the letter, and the default sidebar still shows up. Everything else works: the template shows up in the drop-down, the page publishes with the dummy text I’ve entered — just no custom sidebars. (I’m using v1.8.) (By the way, thanks for the clear instructions. Clearest I’ve seen.)

    • kalengi
      March 12, 2011 at 15:25

      Hi Cannolo,

      Two things come to mind that may sort you out:

      1. If you don’t want the default sidebars showing up, then remove the code <?php thesis_sidebars(); ?> from places_template_functions.php

      2. Read the section titled Update: at the bottom of the tutorial. It may explain why the custom sidebar is not showing.


  35. March 13, 2011 at 07:09

    Kalengi, thanks for your reply. That “thesis_sidebars” code was in there, and I took it out. I also checked the update, which I had taken care of before. It still doesn’t work. I’ve double-checked everything. What else could it be?

  36. March 13, 2011 at 08:26

    I also tried this on a test site running These 1.8, with and without plugins activated. Same result: template shows up on the edit-page page, and the “Places” widget menu shows up in Widgets. There’s just no Places sidebar.

    • kalengi
      March 13, 2011 at 12:51

      OK, if you page is at a location I can access, then I could have a look. Please message me the link using the form on the blog’s sidebar.

      • Cannolo
        March 14, 2011 at 21:06

        Sent. Thanks.

        • kalengi
          March 14, 2011 at 23:18

          @Cannolo I got your message and tried accessing, but there were access restrictions. I’m not sure whether you’ve received my response on mail 🙂

  37. April 8, 2011 at 21:43

    I’m new to Thesis but I cant get Thesis to do what I’m wanting for my real estate web site. Most of my pages will be 3 column content in middle with a sidebar of menus on either side. Questions are (1)Is it possible to have custom page that contains only one side bar on the right that shows different menu items to sidebar 1 & 2 on the other pages.{A 3rd men} and(2) Is it possible to modify the side bar padding/text size of the sidebar menus without it effecting the main nav? (They take the main nav bar foremat, which doesn’t look right on the sidebars, looses to much space between menu items)

    • kalengi
      April 8, 2011 at 22:10

      Hi Steve,

      Yes, it’s possible to create a 2-column custom page and it’s also possible to format the sidebar menus independent of the main nav. You can use the contact form in the blog’s sidebar to describe in more detail what result you’re looking for and then we can go from there…

      Thanks 🙂

  38. Perry
    April 27, 2011 at 02:11

    Wow. This is an amazing tutorial. Would love to contribute a donation to you.

    • kalengi
      April 27, 2011 at 03:29

      Hi Perry,

      What an awesome thing to do! Sure, just write me via the contact form in the sidebar and we can go from there 🙂


  39. May 13, 2011 at 05:41

    For anyone out there who is having difficulty with Thesis or need some special customization, I would recommend you dont waste any time and just contact Alex as I did. Not only does he answer questions asked on his blog (Which I found many many dont do) but he is willing to help with special custom work as he did for me when I needed something extra tricky on my site. He listened, made sure he know what I wanted and then delivered exactly as he said he would within a week. It works perfectly, great job Alex and thank you!!!!!

    • kalengi
      May 13, 2011 at 13:37

      Thanks very much Steve for this wonderful comment! It was truly a pleasure setting up the custom template 🙂

  40. May 21, 2011 at 20:02

    Hey Alex,
    Did you get my email about the custom template problem I found the week later where it has reduced in page width, compared to the pages before the custom change?
    Still shows the same pix wide in view source but it is smaller. Check the search pages, which is still using the wrapper from before the change and then check the width of any other page not part of the search sub domain and you will see they have reduced in size. Can you correct it please?

    • kalengi
      May 21, 2011 at 21:12

      Hi Steve,

      I got the message and responded a few days ago, so I’ve been awaiting your response. I’ve just re-sent it so let me know whether you’ve received.

  41. July 19, 2011 at 21:31

    Thank You 😀

    • kalengi
      July 19, 2011 at 23:01

      You’re welcome 🙂

  42. August 28, 2011 at 21:42

    Hi Kalengi, thanks for post. I have a question. I’m doing it step-by-step, but after 3rd step, my template doesn’t listed in template’s dropdown? why? please help me)

    • kalengi
      August 29, 2011 at 00:38

      Hi Karlen,

      The first cause I can think of is that the file is located in the wrong folder. Confirm that the places_template.php is located in Thesis template folder.

  43. October 11, 2011 at 15:54

    Having some trouble… I am able to see the Places Template when creating a new page, but it shows an asterisk like: Places Template *
    I am not advanced enough to know what is wrong. And when I go to view the page nothing seems to have changed.
    I Greatly Appreciate your help!

    • kalengi
      October 11, 2011 at 17:00

      Hi @RootedUp,

      I think the asterisk is coming from the commenting in the header of places_template.php . Copy the code again exactly as it is in step 3 (Create the template placeholder file).

      • October 11, 2011 at 17:58

        Thank you! Well the asterisk is gone, but I still can’t view the page in the new template…

        • kalengi
          October 11, 2011 at 18:37

          It’s tough to figure out what the problem could be with out more details. You can use the contact form on the sidebar to send me your site’s login details so I can have a look, if you don’t mind.

          • October 14, 2011 at 22:49

            I am getting the widget to show a text box on the left, but I still have theme content showing on the page…

          • kalengi
            October 14, 2011 at 23:06

            We can have a look at this right now if you’re available.

          • October 18, 2011 at 21:50

            Hi, thanks for all your help, I still am experiencing a small problem when I try to replicate this to create a second page from these instructions. Please see http://polibama.com/subscribe/ … the content of the homepage is showing up below the custom content for the “Subscribe” page.

  44. November 24, 2011 at 06:13

    I can’t get this to work for the life of me. I am not new to PHP, wordpress, nor templating. I really wanted to start using hooks but I am about to give up.
    Why can’t I just add a custom_template_name.php, enter my hooks, and be done with it?
    This is insane. I am trying to create a custom page.

    So instead of this, I tried to just use the if_catagory() to call a page catagory using the custom taxonomy plugin but thesis is ignoring that for some reason also. Does anyone know of a basic, single page layout custom template with how to add it?

    • kalengi
      November 24, 2011 at 12:30

      Hi @badjesus,

      Yeah, Thesis takes some getting used to 🙂 The reason it doesn’t work with file-based templating is that all the templates are defined in code using the hook system. You just need to learn the right hooks to call for the page structure you desire. If all you want is a single-column page layout, then pick the “No Sidebars” template option when creating a page.

  45. December 7, 2011 at 04:07

    How would I use this process to create multiple page templates? If you have to select “custom page” when you are choosing which template to use, how would that work with multiple templates?

    also, is there a way to create a left and right sidebar for each template?


    • kalengi
      December 7, 2011 at 10:02

      Hello @nikers85,

      The code as it is assumes that you’ll be using only one customized template. In order to have two or more, you’d have to change the code to detect which particular template was selected for the page and then run the code for that template. Such info could be placed in a global variable before swapping out the template name. I’d need to look into that scenario a lot closer in order to know what sort of information has to be kept around, but generally that’s the approach I’d use. Oh, and you need a separate template file for each template you create so WordPress can pick it up and list it.

      Now about the columns… Thesis already has the sidebars inbuilt. Unless you’d like different columns on different templates to perform functions that are not uniform across the site, I see no reason why you cannot use the sidebars that Thesis provides. To call up the Thesis sidebars, use the code thesis_sidebars();.

      To create additional non-Thesis sidebars, use the code in the function places_ad_column() together with the register_sidebar() function and remember to replace ‘Places Ads’ with the name of your new sidebar.

      • December 7, 2011 at 21:14

        WordPress will automatically load a variety of templates, if they are available to the theme. Breaking out all the Thesis layout functions lets one mix-and-match in arbitrary templates. Easier, more flexible and portable then attempting to manage page rendering by globals and $post->ID. Disclaimer: I sell a very expensive product which does this.

        • December 7, 2011 at 21:33

          kalengi :
          Hello @nikers85,
          To create additional non-Thesis sidebars, use the code in the function places_ad_column() together with the register_sidebar() function and remember to replace ‘Places Ads’ with the name of your new sidebar.

          I could do just the sidebar part without the page templates. I really just need to replace sidebar 1 and sidebar 2 on specific pages with new sidebars, any suggestions on how to make that happen?

          • December 7, 2011 at 22:13

            You could probably do what you want with a simple hack of the Genesis Simple Sidebars plugin.

  46. December 7, 2011 at 23:35

    This plugin does the trick! Similar to the Genesis Simple Sidebar plugin.

    Thanks for all the help!

  47. February 6, 2012 at 23:17

    It still works great in Thesis 1.82. Now, does anyone know how to substitute in a unique header for the page? Help!

    • kalengi
      February 7, 2012 at 02:25

      Hi Susan,

      In order to modify the page header, you need to utilise the header hooks. The steps involved are:

      1. In places_template_functions.php look for add_action('thesis_hook_after_content_area', 'places_page_template_swap_after_content');
      Below that insert the code:

              add_action('thesis_hook_before_header', 'places_page_template_swap_before_header'); 
              add_action('thesis_hook_after_header', 'places_page_template_swap_after_header');

      2. Add the following functions to the same file:

      function places_page_template_swap_before_header(){
              if (is_page()) {
                      global $post;
                      $page_template = get_post_meta($post->ID, '_wp_page_template', true);
                      if($page_template == 'places_template.php'){
                              add_action('thesis_hook_header', 'places_page_header');
      function places_page_template_swap_after_header(){
              if (is_page()) {
                      global $post;
                      $page_template = get_post_meta($post->ID, '_wp_page_template', true);
                      if($page_template == 'places_template.php'){
                              remove_action('thesis_hook_header', 'places_page_header');
      function places_page_header(){
              global $post;
      		<div class="places_page_header">
                          <h1>This is <?php echo $post->post_title; ?></h1>

      That should do it! Modify the function places_page_header() to display whatever unique header you want on the places pages.

  48. February 6, 2012 at 23:23

    I was thinking one way to do it is use a conditional tag with a header function. But the is_page_template tag isn’t working.

  49. April 7, 2012 at 02:37

    What’s the easiest way to adjust the site width just for specific pages? My first stab was to make a new custom template page, call the thesis_html_framework, then immediately modify the container parameters via jquery .css() calls using a hook after html. This works, but the site can sometimes render with the normal width, then snap wider. I’d like to somehow prevent the current css from loading (set in the thesis backend gui) and have specific css for these pages that I specify using a template page. Do I clone and hack up the thesis_html_framework function?

    • kalengi
      April 7, 2012 at 05:44

      Hi Sean,

      The first idea that comes to mind is changing the page class and letting the css adjust accordingly. The body_clas filter is perfect for this kind of task.

      • April 17, 2012 at 02:18

        Yup, that’s perfect. Thanks!

  50. November 27, 2013 at 15:36

    I am a professor of physics and I have recently installed Thesis 2.1.4 on my blog http://yashplus.com
    I want to display my home page just like Pinterest.com board. i.e. small rectangular pages with little excerpt and when somebody clicks one of them, he will be redirected to that page. I want this on my home page i.e. without widgets. Can I do that? Please guide. I have been searching it since long. But nobody helps. I read the highlighted comment on your site and thought that you might be a source of light to me in dark.
    Please help

    • kalengi
      November 28, 2013 at 03:10

      Hello yashplus,

      I’d be glad to help. Send me a message through the contact form and we can take it from there.

  1. May 16, 2010 at 17:06
  2. May 16, 2010 at 21:19
  3. May 17, 2010 at 02:12
  4. May 17, 2010 at 07:00
  5. May 21, 2010 at 23:55
  6. July 24, 2010 at 15:01

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: