Thesis Tutorial: Multiple Custom Page Templates

February 25, 2009 · Comments

in Articles, Internet, Technology, Tutorial

thesis-binary

I have been working with Thesis for a little over a month now. Thesis is a relatively new templating platform for WordPress. Thesis has unmatched SEO, cross-browser compatibility, and top-notch HTML + CSS architecture. This website runs on Thesis.

I was looking through the Thesis forums and tweeting with others on how to get a solution to an issue. The issue has to do with creating custom templates. I want a custom home page design. I also want a custom template for other pages. Basically I want multiple custom templates available under one design. I have tried to explain what I have found below. I welcome your comments and ideas. There may be other ways to do this (usually is) but here is how I did it. Hopefully this can help others.

A Little Thesis Primer

If you are familiar with Thesis you can probably skip to, “Getting To It.” The way Thesis works is to keep all customization inside of one folder–that is part of its genius. Whenever the templating system is updated you overwrite the entire file structure, save your custom folder, and replace that back in and voila you have arguably the best templating system under the hood while keeping your design in tact. This may not seem like much to the layperson, but for those of us that design and develop web sites on platforms like WordPress it is a godsend.

So back to multiple custom templates inside of Thesis.

All of the custom files sit within one folder in ~/wp-content/themes/thesis/custom/

Image of folder structure of where custom files sit inside Thesis

Every customized design using Thesis has their custom templates, css, and images stored within this folder.

To create custom page templates you need to use Thesis’ ingenious “hook” system that allows you to tinker with the components of any part of the standard layout or, if you are brave, roll your own layouts and custom designs. The best entry-level instruction I have found for understanding and using “hooks” is at the web site of Sugarrae: here it is.

Once you have the basic understanding of “hooks” under your belt, have your designs ready to go, and have some WordPress chops, you are ready to create multiple custom page templates.

Getting To It

First thing you need to do is make sure you have your “home page” set to really be the home page. Whenyou are logged in as the admin go to settings/reading. “A static page (select below)” should be set to your homepage. See this image:

homepagesettings

Once I have done this I then need to make sure I have selected the “Custom Template”option from the drop down menu on the right side when you are editing any page (not posts!):

picture-2

So, first I want a custom home page template.

In the file thesis/custom/custom_functions.php I added:

/* HOME PAGE CUSTOM TEMPLATE */

function home_pagecustom() {
/* check to see if homepage. has to happen inside the function */
if (is_home() || is_front_page())  {
?>
...Your custom layout goes here...
<?php } }

/* Now we tell Thesis to use the home page custom template */

remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
add_action('thesis_hook_custom_template', 'home_pagecustom');

The code above has been whittled down to show only the essential code. It works to display a custom home page as long as you have selected “custom template” from the pulldown menu when editing the ‘home’ page.

You may insert any HTML and style it in the custom.css file. Be sure to save custom_functions.php and custom.css and upload to your ~/wp-content/themes/thesis/custom/ directory.

One Custom Page Down.
How About A Second?

So how do you add another custom template after defining the home page template?

You need to define another function for your next page template. You can add as many functions (think page templates) that you like. Each one needs a unique name. You also need to define the conditional properly. You need to make sure that the conditional is within the function—it will not work outside of it.

Use the right *if* statement to make sure you apply the right template to the right page. I typically put the page tag and the page ID—a type of insurance. You can find a page ID by hovering your mouse over the link to edit the page when viewing a page list within the admin area of WordPress.

This example below is testing for the “press page” and if it is, puts the WordPress content on the left side of the page and both sidebars to the right:

/* CUSTOM PRESS TEMPLATE */

function new_presspage() {
if (is_page('press') || is_page('512')) { ?>

<div id="content">
<div class="post_box">
<div class="headline_area">
	<h2>Your Headline</h2>
</div>
...This is where your content goes...
</div>
</div>
<div id="sidebars">
<?php thesis_build_sidebars(); ?>
</div>		

<?php } }

add_action('thesis_hook_custom_template', 'new_presspage');

Since you already invoked the “remove_action” on the ‘thesis_hook_custom_template’ in order to replace the home page first you do not need to repeat it.

The example above looks exactly like the standard content column on the left with dual sidebars on the right. I used a custom template in this instance because I wanted to perform specific calls to the database and produce specific lists of posts. Since I am doing it this way I also create the ability to style the page however I like through the use of creative CSS implementation.

Wash, Rinse, Repeat

You could then repeat the code above and apply it to any number of specific custom templates you would like. All you need to do is

  1. create a unique function name
  2. reference the right page in the conditional
  3. make sure conditional is within the function
  4. place whatever content you would like within the proper divs
  5. style the content within the custom.css file
  6. make sure your page within WordPress has the custom template selected as its template option
  7. test, test, test

That’s it. This tutorial should get you well on your way to creating multiple custom page templates within the single custom_functions.php file. If you have any questions, comments, or suggestions I welcome them below.

Hope this helps.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Twitter
  • StumbleUpon
  • Technorati
  • Facebook
  • Google Bookmarks
  • NewsVine

Do you need help with Wordpress, or the Thesis theme?

Image of DoubleMule certification. I'm a Thesis Certified Designer.

If you are a web designer or web developer needing help, or a 'do-it-yourselfer' looking for a professional Internet presence I can help.

If you need help with a specific WordPress or Thesis theme issue or a complete website, I offer consultation, complete web design, and web development services.

Get in touch and we can talk about your needs and start the process.

  • Great tutorial, timely for me as I am combining my current website with my blog and this helps me no end in how to start to reconfigure things. Thanks again for posting this
  • No problem Kathy. I struggled with this code for a while and thought that it might save a few people many hours of frustration. Glad it helps. Let me know if you have any questions.
  • Jen
    This is such a great tutorial! I've been playing around with Thesis for a while now and it's been quite a ride. I just finished my first site using it and looks like your tutorial would have helped immensely - especially since I'm a total novice.

    So heres my question (forgive my ignorance!): The first page on the site is a grid system of images which are links to each artists page. I used 'stack' to align the images but just found tables yesterday and it seems that might have been the better option? Could I create a table, use the code for a page template, and then use that for the home page thereby keeping the ability to change out images easily?

    Thanks again for sharing your work!

    best,

    Jen
  • Jen
    opps! I probably should have sent the link along! jen11show . com
  • Hi Jen,
    Based on what you are describing and the link you sent above I think you can do what you want. You can certainly create a page template and apply it to any specific pages you like.

    So it is entirely possible to apply a template to just one page, or to every page but a specific one. You just need to structure your logic correctly.

    If you can be more specific I can try to help.
  • Great tutorial. Hooks drive me crazy. What I've been trying to do is create additional sidebars, but haven't had luck so far.
  • rumblepup,
    Thanks for the compliment. I think I may do a tut on extra sidebars. You are the second person I have come across who would like to do that. Are you wanting a 3rd sidebar? What kind of sidebar configuration are you after?
  • doug
    Ok, but one question. My Reading drop down list doesn't list "Home" as one of the options as you showed after "Gettin to it" above. Yet, my site definitely has a "Home" link on the nav bar. Should I create a page called "Home"? to use your code above?

    The confusing this is that right now, my blog posts all show up on the page called Home, but I never created a page called Home. I guess that is a WP default or something?
  • Hi doug,
    Yes you do need to create a "home" page and then select it from the drop down menu. What you are seeing now is the default WordPress behavior. Let me know if you have any questions.
    Hope this helps.
  • angintx
    I created a home page but do not see "Blog" as an option on Posts page. What am I doing wrong?
  • doug
    ok, one more question: do I need to copy/paste the entire code from Thesis for each custom page, or does every custom page template already include my current look?
  • hi doug,
    Once you indicate a custom template and follow the instructions above, you will need to code each different layout, or *look* that you would like and use the right logic to get them to show up on the proper pages.
    Hope this helps.
  • It is very helpful. Thanks...

    How can be category pages customized in the same manner? I need to order post based on custom fields. I have done it on homepage using your tutorial but need to do it on category pages as well?
  • Thank you! very helpful
  • I like this process; really helpful for custom pages I will be creating. However, I'm looking to create a custom homepage using my own html, and none of Thesis body content.
    Is this possible by removing actions from various hooks, and adding my custom template as described using the (thesis_hook_before_html)?

    Or is it preferred to create a server subdirectory instead for all Wordpress pages, and manually link to them from the home.
    Just trying to save some code time, without having to copy/paste meta information with future updates.
  • I've got the same question as Mario. Thanks
  • Hi Amit,
    I believe you could use the 'is_category' or the 'in_category' conditional tags to test and then implement the code you would like. For example:

    function new_categorypage() {
    if (is_category('5')) { ?>......


    In the code above you would substitute your category ID where the number "5" is.

    You can find the syntax for category testing here:
    http://codex.wordpress.org/Conditional_Tags#A_C...

    Let me know if you have any questions.
    Hope this helps.
  • Hi Mario and Lisa,

    To the best of my knowledge you should be able to do that without having to create a separate directory.

    The only clarification I need to help me understand what you are asking is when you say:

    "I’m looking to create a custom homepage using my own html, and none of Thesis body content."

    Do you mean you want to use no html generated from Thesis AND WordPress?

    Or do you mean only the HTML content generated in the content area? (header, sidebar, footer all generated by Thesis/WordPress?)
  • I'm looking to have essentially an HTML splash page that then links to a thesis site.
  • Hi Jen,
    You *should* be able to upload your index.html file to the root level via FTP and it will supersede the index.php file from WordPress. WordPress has behaved that way for me in the past. Just ensure you link from your index.html file to http://www.yoursite.com/index.php

    Once caveat, the home link inside of WordPress may take users to http://www.yoursite.com and thus they will see the the splash page again. Just be aware of that. You could hard-code the link inside of custom_functions.php.

    Hope this helps.
  • Same here. I'd only like to replace the HTML content in the content area. My concept is to use this as my homepage:
    http://www.kingoftheocean.com/index2.html

    If we can do that by defining the necessary html in the custom_functions.php and custom.css files, it gives us an easy framework. The question is what hooks to use, and actions to add/remove.
  • That works - but yes, the home link goes back to the splash page. I'll have to link it as you described.
  • Thanks for the hard work! Is there anyway to strip all of the no sidebar options so it's just a squeeze page, no, comments or footer?
  • Mario and Lisa,
    Yes. You will find that the home link will take you back to the root level, in this case index.html instead of index.php.

    You will need to create custom navigation to override the home link and change it to index.php. Here is an example:

    remove_action('thesis_hook_before_header', 'thesis_nav_menu');
    function add_custom_nav () { ?>
    [ Put your custom navigation in here ]
    <?php }
    add_action('thesis_hook_before_header', 'add_custom_nav');

    This will remove the standard nav and replace it with your own, custom defined version.
    Hope this helps.
  • hi lawton,
    thanks!
    you can certainly place only the content from your specific page. I would follow the "press page" example above and then only put the_content() into the page.
    Let me know if you have more questions.
  • Hola,
    Thank you for the post!

    Question: I see you used a function thesis_build_sidebars() but I can't find any documentation on this on the Thesis site.
  • I'm new to Thesis and I'm trying to understand all of this. I guess I should ask this in their forum but I like your site so much I wanted to ask you. :)
    Which tutorial should a beginner start with before trying to understand what you are explaining to do here with custom css and such? If that makes sense? I've looked but not sure where the beginning is.
    Because Thesis claims less coding, don't have to be a programmer etc., yet I still just don't get it.
    But I'm having a ball trying to learn! Just not sure how to get to point B since I haven't been to point A.
    For example, I'd like to create drop down menus for my navigational bar across the top or in the sidebar(s).
    Thanks!
  • Hi Gregory,
    Yes. You would not find any reference on the Thesis website to that function. It's buried in another part of the theme. I have been on Twitter with Chris Pearson, the Thesis developer, and he was gracious in answering my questions. He directed me to the location of that function.

    It is here: ~/themes/thesis/lib/html/sidebars.php

    NOTE: If you modify any files outside of the /custom/ directory then you run the risk of not being able to seamlessly update Thesis.

    Hope this helps.
  • Hi MirzaLou,

    If what you want is a tutorial on customizing the navigation with drop downs the best tutorial is at Kristarella's website.

    As to your question on where to begin with your customization I think it depends on what your goals are. What things do you want to change?

    If you look at the entire scope of changes it may cause you to feel overwhelmed. However, if you tackle each item singularly you will customize your site and learn piece, by piece.

    So I would suggest figuring out what you specifically want to do, break it down into specific tasks, then figure out how to complete each of those tasks. It will, no doubt, involve a bit of html, php, and css depending on what you are after.

    Let me know if you have any questions.
    Hope this helps.
  • Hi there, thanks for the post - this is just what I'm looking for but I have no idea what language you're speaking. Wondering if you can shed some more light on this. I get the feeling I need a "Dummies Guide" to php and css before I throw my laptop out the window.

    I need to use the Thesis home page with a 3 column layout (sidebar1, content, sidebar2) and the teasers option. But when a user jumps to a category and a page have a typical blog page (content, sidebar1 (maybe sidebar2 as well)).

    I'd like to learn this on my own, can you point me to where I should start reading. I honest think I need a primer. I've tried following through the Thesis forum and am lost on most things, the coding is frustrating me.

    Suggestions.

    Thanks Alex.
  • Hi Alex,
    I would setup your homepage using the Thesis settings under the Appearance tab when you are logged in as the Administrator. Get your sidebars, etc. to show how you want using the default toolset.

    Then for your categories and pages I would use the tutorial above to setup your page layout templates how you like. As far as learning PHP and CSS... for me it has been years of self-taught trial and error.

    My education included programming, but it was FORTRAN, COBOL, PASCAL, and some Machine Language for good measure. I learned principles of programming from taking those classes which help me now, but aside from that its hack and see what sticks.

    You can try this link for CSS help: http://www.w3schools.com/css/

    And for PHP this may help:
    http://www.w3schools.com/php/

    Hope this helps.
  • Actually, Alex explained my frustrations much better, and in your response to Alex you suggestions the following:

    You can try this link for CSS help: http://www.w3schools.com/css/

    And for PHP this may help:
    http://www.w3schools.com/php/

    I believe this is what I referred to as "point A" for which I will be spending some quality time.

    Thanks!
  • Thanks for this awesome tutorial, and for the link to the Sugarrae article on hooks. Despite the excellent advice, I still don't have my custom templates working the way I want.

    I have a simple home page, which I've already set up. I want subsequent pages to be very similar - same navigation, smaller banner across the top, fewer sidebar elements.

    I've got the custom_functions.php file downloaded, but I'm not sure what to enter for the custom content. I don't want to do the html - I want to duplicate *most* of what's on the other pages. Where do I get the code? Do I copy it from the various templates in the Wordpress editor?

    Can't help but think I'm missing something obvious here...
  • Hi Julie,
    Yes, you do get the source code from other files that are setup how you like combined with the customizations that you want.
    You also need to identify the page you want to have this custom template applied to and develop the right logic so it happens how you want it to.
    You asked where to find source code that is being used for the pages. You can find it in here. NOTE: Don't edit files inside this directory or you are playing with fire. :-)
    You may open the files in this directory to copy/paste elements into your custom_functions.php to play around and get what you are after.
    Hope this helps.
  • Paul B
    When I try tofind a page ID by hovering...over the link to edit the page when viewing a page list within the admin area of WordPress., it does not show the page ID. It only shows the name (title) of the page.

    Question 1, Is there something that has changed in WP 2.7 or Thesis 1.5 that behaves differently than when you wrote this tutorial?
    Question 2, Is there an alternate way of finding a page's ID? Besides opening up the DB and finding it there, of course(~:
  • Paul B
    Nevermind... I found out why! As of wp2.5 the ID is not shown anymore.

    Here is a plugin to display it though, and it works well for me.
  • Hi Paul,
    Thanks for the link to the plugin.
    Thinking about this ID issue I realized I may not have been specific enough. By default you should see it in the bar at the bottom of your browser, not necessarily on the 'tool tip' hover. If you have changed your permalink structure in the admin tools of WordPress then this would not work either (as is the case on this website) and the plugin would be the way to go.
    Let me know if you have any questions.
  • Hi there,
    This is somewhat what I have been looking for Thanks.
    I'm new to blogs all together and starting a new RE site.
    see link- http://www.carealproperties.com/

    I would like to set sub pagers to my site a little different than my home page and my two question's are as follows:

    1) As you can see my areas of service are in the left sidebar and those links take a user to a static city page that also has the left & right sidebar. (I would like to keep the left sidebar on all pagers.) On the sub pagers only I would like to change the right sidebar to break up the cities into neighborhoods.

    2) On the sub pagers I would like to have a static introductory section at the top of each of the cities and neighborhood pagers that will not get lost in the archives. In other words I would like any posts to be below the static Introductory.

    I don't even know if it is possible and I would greatly appreciate advice. ")
  • Hi CARP,
    Yes, you most certainly can do what you are after. In fact I am in the process of finishing up a tutorial on multiple-sidebar-options. In the default WordPress/Thesis environment you only have 2 sidebar options. My tutorial will show you how to create as MANY sidebars as you want/need and how to use it in combination with the principles in this tutorial to get exactly what you are after. I should have this tutorial published within the next week.
    Hope this helps.
  • Great tutorial. I'm a relative newbie and got it working on my test site using your example. However, my goal is to create a custom template that uses a different header image than the rest of the site. The navigation tabs would stay the same; I pretty much just want to be able to specify a certain header image for certain pages. Your tutorial seems to just include the stuff under the header and before the footer. Any advice on how to proceed?

    Thanks!
  • Hi Jason,
    Thanks for the compliment. As is the case in many things WordPress there is more than one way to tackle what you want to do with your headers. However, since we are working within Thesis I think the best thing to do is to build a subroutine that tests for pages/posts/categories and then inserts the correct header. Then you could run that subroutine in the standard Thesis template using hooks, or if you have custom page templates you could reference the 'custom_header_subroutine' within it.
    BTW, checked out your website. So cool! I needed a reminder about escaping adulthood. Is that the website you are looking to use Thesis with?
    Let me know if you have any questions.
  • Nicky
    Hey Berchman,

    Thanks for the tutorial. This is somewhat related to what I'm trying to do.

    I have a query. I want to show two sidebars (3, and 4) different than the ones displayed on homepage and rest of blog. How do I go about it? I want the layout to be s3-content-s4.

    Any help on this would be great!

    Thanks
  • Hi Nicky,
    Thanks. I should have the sidebar tutorial online by end-of-day Monday (hopefully sooner if possible). Stay tuned.
    Cheers,
    berchman
  • Nicky
    That sounds really good Berchman, I'll be looking forward to it. So far, I've managed to add the sidebars but I'm not able to get the layout of s3-content-s4.

    Thanks,
    Nicky
  • Mary Baker
    I am using Thesis 15 and want to have custom templates for some of my pages. How can I add content within the dashboard with a page that is using a custom template?
  • Hi Mary,
    You first need to create a new page and add its content. While viewing the page you make sure you have "Custom Template" selected from the right side pulldown menu (look at the tutorial above, it is spelled out). Once you have that done you need to go through the coding process I have outlined above ( in custom_functions.php ). This way the page is looking for its custom template and it is applied appropriately. Hope this helps.
  • This was very helpful. I've been wanting a custom Thesis homepage for awhile now and just never took the time to learn how. I am testing this on my local machine and it works like a charm. Appreciate it. :)
  • Thanks for the kudos Lisa. I checked out your website. Quite cool. I like how you are keeping it real for people. Great topics, great content. Cheers!
  • paynem
    I too thank you so much for creating this tutorial. More so, thank you for sticking around to answer questions. WOW! That alone speaks volumes about you. :) I also want to point out just how helpful Lisa Irby has been in pointing me to your tutorial. I am grateful. Berchman, do you know someone who will accept a project to build a site using Thesis (with a home page and different inner pages)?

    Thank you!

    Mike
  • Hi Mike,
    Thanks very much—appreciate it.
    In terms of projects, I take projects on and am "open for business."
    If you like just fill out the form here:
    http://www.berchman.com/hire-a-specialist-that-...

    and we can get things started.

    Best regards,
    Bert
  • Hi again,
    I followed all your instructions and can get it to pull the custom template (which is just a grey box for now). The problem is that the custom template doesn't pull the content that I have written through the dashboard. It's only pulling the content that I put in the custom_functions_php file. I don't know php so I'm a bit blind here. My intention is to be able to add all content through the dashboard and have one sidebar (sidebar 1) on the right. Any help is SO appreciated. Thanks!
  • Hi Mary,
    You most likely need to run the WordPress "loop" and pull the content you want in that way. You can read more about the loop here:
    http://codex.wordpress.org/The_Loop

    Here is an example I use to pull the content for a homepage. You must have the page ID'd as the home page in Settings/Reading



    function home_pagecustom() {
    if (is_home() || is_front_page()) {
    ?>

    <div id="home_top_message">
    <?php if (have_posts()) : ??>
    <?php while (have_posts()) : the_post(); ??>
    </div><div id="home_message">
    <?php the_content( ); ??>
    </div>
    <?php endwhile; ??>
    <?php else : ??>

    Not Found


    Sorry, but you are looking for something that isn't here.


    <?php include (TEMPLATEPATH . "/searchform.php"); ??>
    <?php endif; ??>





    Let me know if you have any questions.
    Hope this helps.
  • George
    Hey berchman,
    Thanks for the great stuff. On a May 9th comment (above) you said something about a tutorial you were making on creating pages with their own custom sidebars.

    Have you got that done yet or can you direct me to a source where I can learn about how to have different sidebars on different pages in Thesis?

    Thanks.
  • Nicky
    Yo Berchman, I'm eagerly waiting for your tutorial to have different sidebars on different pages.

    Regards,
    Nicky
  • George and Nicky,
    Was having issues with my own Thesis install and had to work those out.
    I should have the new sidebar tutorial up soon. Stay tuned.
  • GP
    Lovely, now I'll just get my smart hat on and reread Rae's 'hooks' "clarification' and try not to hurt anyone in the meantime. HOWEVER -- if anyone can point me to who can do this for me for $, I'm all ears. Thanks ~ !
  • I've read and re-read this article, as well as your more recent post on custom sidebars. I still have a couple of questions I hope you can help me with:

    1. I have a three column layout, with sidebars on either side of the content. For some pages, I'd like to get rid of the left sidebar and enlarge the content area. What's the best way to accomplish this?

    2. I use conditionals on my custom_function file to create content sensitive sidebars. It's not pretty, but it gets the job done. For pages, would the better way be to use the custom template, or does it not really matter?

    Thanks.
  • Hi Dough Roller,
    For #1 if it is indeed for 'some' pages then I would create a custom page template and build the template layout to have only one sidebar. I would also "ID" the content area as 'content-wide' and then use css to style appropriately.

    For #2 it depends. Many times there are multiple ways to 'skin it' so its just a matter of efficiency. If what you have going works for your purposes then 'if it ain't broke, don't fix it."

    Hope this helps.
  • Great article. Allowed me to get some of the home page lookin just as I wanted. But now I'm stuck again. I've inserted my own static code on the home page now I want excepts of my posts to be listed - I've tried putting all the loop commands in my copy of your code and I only get a blank copy of my Home page - with lovely sidebars, header etc. Please point me in the right direction to get the piece I'm missing. I checked the forums to see if anyone else had posted but I didn't see anything so I'm back to ask you - since I'm sure you know. Thanks a lot
  • Hi Jennifer,
    If what you want is to list just the excerpts of your posts you should refer to excerpt basics here: http://bit.ly/19mirP

    If you email me your custom_functions file I could take a look.
  • Hi, Thanks for this tutorial. Im still a little unclear. On my site I basically want the home page to be 2 columns and all the rest of my site (which are just different categories for my blog) to be 3 column as they are now.

    I want to put the FCG on the home page only, in one of the columns and the other column would have the most current blog post. I want the nav bar to be the same on all pages/posts.

    Ive created a page called "home", and set it at "custom template" and called it "static home page" and put the code in "customs_functions." But not sure what I do now. Do I have to do the styling by code or can't I go in and set up the columns for this home page in "thesis design options." Am I making any sense here? Thank you for any help. I am a beginner but Ive accomplished alot (in my mind) so far in my newbie state : )
  • Hi Allison,
    You are definitely on the right track. The key is inside custom_functions.php. The function you write to replace the home page has to be called by the proper "hooks." If your homepage looks like the rest of the site, and you have double checked that you have it set for 'custom template' in the pulldown, then I suspect the culprit is how you are using Thesis hooks to call the function and replace the homepage template. If the hooks were working your homepage would look different than the other pages, even if your home page template was not 100% accurate. The hooks would replace it anyway.

    Take a look at the references about hooks and how you have them implemented. Then let me know if you have any questions. Hope this helps.
  • Thank you! I have been doing some modifications on Thesis and your little guide here rocks Mr!

    Thanks / Marcus
  • BTW, I wrote a simplifed version on how to create custom sidebars to go with your custom pages over at the official support forum: http://diythemes.com/forums/support/6039-sideba...
  • Hi Marcus, Thanks for the comments. BTW you might check out my custom sidebar tutorial as well. Let me know if you have any questions.
  • Andrew
    Nice tutorial. I'm wondering, is it possible to put some custom php inside these hooks? What I'm trying to do is insert a shopping cart (which calls to a separate MySQL database) inside a specific Thesis WP page. I've done this in other standard WordPress templates, but having a hard time inside Thesis. Any advice?
  • Hi Andrew, You can put custom php inside the hooks. It just a matter of tweaking until things work as you want. You may also want to checkout Open Hook. It may help as well: http://rickbeckman.org/thesis-openhook/
  • Your coding started with div id="content" . How do I ensure that the standard header and footer will remain intact and that I'm just replacing the middle area (regardless of how many sidebars I have)?

    I want the header and footer but, three static columns for the middle that I'll add javascript to.

    Your tutorial kicks some ass, man.
  • Hi Shane,
    As long as you are using standard Thesis templates the code in that tutorial only replaces the center content. The header and footer show as they should on all other pages/posts. Let me know if you have any questions.
  • Alex
    This tutorial is great, but I am still having issues.
    I want my header, footer, and sidebar to remain the same, but I am placing content within the content div. It displays only the header and the new content, but not the sidebars.
  • Alex, do you have a link you can email me so I can take a look? It sounds like a div nesting issue.
  • Is there a way to have it register the custom templates inside Wordpress instead of basing it off the page id? That way, the user could just pick it on the sidebar while authoring the content.
  • Hi Melvin, You are wanting the custom templates you create to show in the sidebar pulldown. To the best of my knowledge within the Thesis framework that is not possible. I have nto read or heard of someone being able to do that. However, if given enough time to work on it I imagine anything is possible. I would post this question to the Thesis forums to the larger Thesis audience.
  • Hi - I've persevered with this (as well as the sidebars tute). I put this in custom functions:
    function home_pagecustom() {
    if (is_home() || is_front_page()) { ?>



    <?php the_title('', ''); ?>








    Not Found
    Sorry, but you are looking for something that isn't here.









    <?php } }
    remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
    add_action('thesis_hook_custom_template', 'home_pagecustom');


    and it did something but looked odd!

    So I put this in custom css:
    home_pagecustom{width:820px;}

    And realise that probably not the right call but I tried most other things; still did not look right.

    I seem to be getting these templates to call up; but I just can't get the sitting right! Can anyone tell me what on earth I am doing wrong both with this and my sidebar template. Is it the way I am custom css-ing it.

    Yours patiently and back to the standard sidebars for now!
  • robyn
    So berchman, if I only want to change subsequent pages, can I leave the front page as is (not create a custom template) and only create custom templates for pages I want to adjust sidebars in?
  • aaron
    I have had no need to modify the home page, but have needed an extra template (client needs to show two authors content on the same page and styled differently). So, I created this:

    function another_page() {
    if (is_page('another') || is_page('134343')) { ?>

    stuff goes here

    <?php } }
    remove_action('thesis_hook_custom_template','thesis_custom_template_sample');
    add_action('thesis_hook_custom_template', 'another_page');

    I do not get an error, but the "template" doesn't show up as an option when I go to create the page.

    How do I get it to show up? thanks
  • aaron
    i think i just figured it out.... you select custom, and then based on your function (if page is _____) it will use that code.
  • Marek
    Man, you just saved my life.
  • Kaz, are you trying this with all pages of the site? Or a specific one? If so, can you give me the exact URL?
    ==
    robyn, yes. you have to apply the template using the sidebar pulldown in the page editor AND specify the page in the custom_function.php conditional.
    ==
    aaron, yes you have it correct and what you explained is what robyn is asking.
    ==
    marek, you are welcome.
  • Sherwin
    Please forgive me if i don't make sense. I would like to have every page in my blog with a different design (not more than 100 pages). Do i have to use Custom Pages for each page. If Yes, will the custom_functions.php page get too long for my blog to work because i see that i have to add each custom page code to the custom_functions.php page. Please help me understand.
  • Sherwin, In theory you have it correct. It really depends on how different each design is. If they are all completely different (quite an undertaking!) then yes you would need custom code for each page. However, if many/most of the pages would share common elements, ie. a certain sidebar will show on pages 1, 5, 27, 45, etc. then you could write functions for each of those page elements and create cascading if-then-else statements to 'mash-up' your pages as you need them to appear. Each distinct page element would need its own function. Let me know if you have any questions. Hope this helps.
  • Great Job Dude.
  • Hi Berchman,
    I like your tutorial, but in a way it doesnt work.
    I followed your steps, but somethings seems to go wrong, i mean there is nothing changed on the page i chose for being the custom template. Maybe it's in the code? Do i only have to copy your code or should i change something? like this: if (is_home() || is_front_page()).

    Sorry for being a noob.
  • Hi Mike,
    Are you certain that in the 'settings/reading' page in the admin area that you have the 'static' radio button selected and then select the appropriate page from the pulldown menu? This coupled with selecting 'custom template' when viewing the page in the 'edit' mode should do the trick.
    Let me know if you have any questions.
    Hope this helps.
  • Berchman,
    Thx for the fast respons.
    I followed the instructions in your tutorial so the settings in reading where done, and the custom template was chosenfor the the home page i checked it a couple of times.
    What would you see when you chose custom_template? A blank page?
    Thx for the effort.
    grtz
    Mike
  • Great tute, and I successfully created a custom page, but I wanted it to be blank, so I could use a full width table on the page, but I think, I'm being restricted by the content function. It seems to only allow my content to conform to my homepage settings. Therefore the content html will not scale to a greater width, the way the no_sidebar template works by default.

    Code used

    /* CUSTOM Blank TEMPLATE */

    function new_blankpage() {
    if (is_page('blank') || is_page('2333')) { ?>


    <div id="content">
    <div class="post_box">
    <div class="headline_area">

    Software And Accessories


    </div>
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    </div>
    </div>


    <?php } }

    remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');

    add_action('thesis_hook_custom_template', 'new_blankpage');
  • Berchman,

    I think the problem was in mine html code,
    Thank to Peter i got the problem solved, i saw the blank page by trying his code, i didn't saw the headline, but probably it's me again ;).

    So i am very happy it works.

    Thx allot guys and keep the good work up.

    A happy Belgium guy

    Mike
  • Hi Mike,
    Glad you got things sorted out. Stay tuned. More tutorials to come.
  • Fixed this, thanks for all the info!!
  • Hi Peter,
    Glad to hear you got it all sorted out. I was going to suggest giving your 'content' div a custom name like 'content-custom-wide' and then controlling that through css to make your page as wide as you like. Let me know if you have any questions.
  • One more Question Berchman,

    How can you merge the content field with the sidebars field.
    If i use display:none; for the sidebars it gives an empty field and the text of content doesn't expand in that.

    I think that this can be usefull for some of us.

    Thx
  • Hi Mike,
    If you want the sidebar not to show and the content to be full width
    across the available space you will need to do that with CSS. Find the
    appropriate < div > and style accordingly.
    Let me know if you have any questions.
  • Hi Berchman,

    I succeded thx to you to do it to change the width of the content.
    But the problem now is that i have to do it in a custom template, for example the first page.

    Thx again and again ;)
  • Hi Berchman,

    I found it! With inline style i changed the width too 100%! and that worked...

    I love it
  • nokiatips
    Oh my gosh, you are the real deal, wow your website creations are simply amazing, congratulations
  • Hi Berchman,

    Me again, is it possible to become an template with a specifiek widget in it(so you can choose).
    I mean for example home page with widget pages, and newsletter page with only the list with different post in it?

    Thx
  • Hi Mike,
    you can create as many custom page and custom sidebar options as you like. With the two tutorials on my site the sky is the limit. Hope this helps.
  • Hi Berchman,

    Is it possible to make a template where a pagge have different widgets then another.
    For example one page with the widget pages and another page with only a widgte links.
    So two different custom templates but with the selection witch widget you chose to display.

    Thx men
  • Hi Mike,
    Yes. It is possible to create as many custom page templates as you
    like AND have as many custom sidebars as you like on as many custom
    page templates. At least I have not had a situation where I've run
    into any limitations.
    It would become an information management challenge though!
    Hope this helps.
  • Tim
    Thanks Berchman - you have saved me hours of messing about, no matter where I have been I have not found any explainations as simple and effective as your - you are a Wordprss and communciation legend. Best wishes.
  • BC
    Very cool tutorial. What if you just want to keep things and add a custom phpfunction within the content div of a page so it executes your script? Where would you add the function because all I would want it is within the video page and no where else on the website. Thanks
  • Hi BC, you would need to write a PHP function to test for that specific page and then insert your custom php function into the proper place within the content div—either before or after the content—and you should get what you want.
  • BC
    Hi Berchman
    Let's say my page on my site is www.mydomain.com/video
    I would then insert something like this in the custom php function page?

    function myvideopage {
    if(is_video()) { ?>
    <?php if (function_exists("vimeorss")) { vimeorss("myfeed", "videos", 10, "", "", 760, "medium"); } ?>
    }

    add_action('thesis_hook_before_content','myvideopage');

    I'm just not sure if I type video page url which would be the page which holds my videos such as mydomain.com/video?
  • chinedu
    how do i add a slide show to the static page similar to voteshell.com? Thanks for the tutorial, new to wordpress.
  • careys
    Dear Berchman,

    I am new to Thesis and have my first site www.makesaleseasier.co.uk with Thesis 1.5.1 and own host Wordpress 2.8.4. Plug-ins are Akismet, OpenHook & SimpleFlashVideo.

    I am trying to remove (or make thinner) the border around the default Multimedia Box. It is a taste issue, but also a test of my learning that I am currently failing at. Please could you tell me if there is a way of controlling the MM box border through the dashboard?

    I have find a tutorial on adding a border (http://www.thesishacker.com/put-a-border-around...) and have tried their code suggestion [/*border around mm box*/
    .custom #custom_box {border: none; } in custom.ss] to get no border without success. Perhaps this is a syntax or code placement error on my part?

    with best regards,
    Carey
  • Very interesting post. I use Thesis on my blog and am very happy with it.
    I have been searching for a theme which can support different designs for category pages for my upcoming website.... or rather what you are talking about. Needless to say that I would be using Thesis... but gotta figure out if I can have the cake and eat it too :)
    Keep up your good work.
  • Brendan
    Hey,

    I have thesis openhook, and m having issues. I have uploaded 10 images (tif files) in to the rotaor folder on my bluehost server, but the images are not showign up on my homepage. Any ideas what the issue may be?

    Thanks

    Brendan
  • Brendan, the images need to be jpg, gif, or png. Tiff format will not work. Hope this helps.
  • Frederik
    Hi Berchman,
    thanks for the great tutorial!
    I tried to implement that stuff but got stuck.

    What I want to do: all my pages have 2 columns: content +sidebar1.
    I'd like the home page to use sidebar 2.

    I tried to call the home page up with this
    if (is_home() || is_front_page() || is_page('14')) {
    ?>
    and later insert the sidebar like this:
    <div id="show-only-2">
    <?php sidebar_2(); ?>
    </div>

    Nothing happens on my site though. My guess is that there is something wrong with my first line of code.
    I have a static page defined as front page, called Home.
    This is how its called when I edith the page:
    /page.php?action=edit&post=14

    Any advice would be greatly appreciated!

    Frederik
  • Hi Berchman,

    Reading your tutorial and comments was really helpful to me, so I thought I'd give something back by showing how I solved a little problem with custom pages: I needed to have selected pages based on the Custom Template show no heading tags and/or no sidebars --which seemed nearly impossible to accomplish with Thesis 1.5.1, especially the latter.

    Here's how I did it:

    /* CUSTOM PAGE TEMPLATE */
    function custom_page_template() {
    if (is_page()) { ?>
    <div id="content">
    <div class="post_box top">
    <?php if (!is_page('1')) { // No headings on page 1, please.
    thesis_headline_area();
    }
    ?>
    <div class="format_text">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    </div>
    </div>
    </div>
    <?php if (is_page('2')) { // No sidebars on page 2, please. ?>
    <script type="text/javascript">
    var content_box_element=document.getElementById('content_box');
    content_box_element.className="no_sidebars";
    </script>
    <?php } else { ?>
    <div id="sidebars">
    <?php thesis_build_sidebars(); ?>
    </div>
    <?php } ?>
    <?php } }

    remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
    add_action('thesis_hook_custom_template', 'custom_page_template');


    The first conditional PHP block will prevent Thesis from adding a headline_area <div> if the current page ID is 1, producing a page with no

    or

    tag above its content.

    The two lines of JavaScript code within the last conditional block will dynamically add the "no_sidebars" CSS class to the HTML element with "content_box" ID if the current page ID is 2, making that page show no sidebars when the "Custom Template" is selected, while other pages based on the Custom Template will still have sidebars.

    You can list one or more page ID's in each conditional block, of course.

    Hope you and your readers find this little hack handy!

  • Giacomo, very creative solution. I am finding Thesis to be extremely flexible. You just need to think things through and you can usually find a solution. Thanks for sharing.
  • Great tutorial and thank you for making it very simple and straight forward. Believe it or not I was looking for this exact info for about 5 days now and finally came across your post.

    One question about the custom code ... How would you display a NexGEN gallery through the custom code in the custom_functions.php page? As it appears right now I only see the 'call' to the page displayed on my page as [slideshow=12].

    Any help or nudge in the right direction you could provide would be very helpful. Thanks again!

    -Jeff
  • andimac
    How do you remove sidebars from a custom page? Probably a really simple question - pardon that.
  • This is a great tutorial. I just got Thesis myself and I'm currently tweaking it for my new design business site. I only have one question: can you link me to any places where they have tutorials on how to build the "custom" layout for these pages? I didn't have a custom home page either and I'd like it to just be like the default Thesis home page, but I haven't a clue how to do that.

    Thanks again for the great tutorial. I have bookmarked your site and will be checking out your other articles.
  • Hi Doug,
    Thanks for the kudos. In terms of "how" to create a custom layout I don't have a resource off the top of my head. However, this makes me think this is a good topic for a tutorial. Stay tuned.
  • Dan
    This is for newbs?

    Reading settings: Why change this? It already does this.

    Switch to custom templates on pages: Why? It works fine.

    The advice might be awesome, but it would be helpful to indicate which problems they are a solution to.

    Thanks
  • Dan, this is for newbs and for people new to Thesis.

    You need to change reading settings and custom templates on pages because the custom page templates will not be inherited otherwise.

    If you want to do some serious customization this tutorial is helpful. If you are happy with Thesis "out of the box" then this tutorial doesn't have much value for you.
  • jennybuttler
    Hi there,
    I would like for Thesis to display the full post upon clicking on the category instead of just the post title. How do I go about doing this?

    My site is simplydelightfuldesigns.com/blog - there are a few tester categories in the sidebar right now, when you click on them, the post titles are in a list.
  • Hi Jenny,
    You would need to build a custom template to handle this based on what
    type of page you are trying to display.

    Your conditional would have to test to see if its listing content from
    category pages, and then deliver the right custom page template.

    Hope this helps.
  • Janie
    This is the simpliest of all questions. When I to to quick edit page, the only template I can choose is default. Where are the other options as you show above
  • Hi Janie,
    You need to click on the "Edit" button, not the "Quick Edit" button.
    Hope this helps.
  • Gordon
    Possibly a really lame Q, but how do I actually call the text from my Page? In your example you have the following code;

    ?>
    ...Your custom layout goes here...
    <?php } }

    How do I insert my custom layout? All that appears on my home page is '...Your custom layout goes here...'!

    I have looked around and can't find the answer - probably because I don't know how to ask the question!

    Thanks for your help!
  • Hi Gordon,
    You need to insert some php to pull content however you like.
    Depending on what you want in that space it could be all blog posts, posts from a specific category, or content from a specific page. All these examples would use slightly different php. A good place to help understand what is going on is to read up on the "WordPress Loop": http://codex.wordpress.org/The_Loop
    Hope this helps.
  • Thanks for your help. I will read up on The Loop...!
  • I'm making an attempt at creating some custom pages for a new site I'm setting up. At the moment it kind of makes my head spin, but I'm hoping I can get it figured out.

    Do you know a site where I'd be able to see what might commonly appear in the space where you have "...Your custom layout goes here...
    "?

    I'm unclear on where I would find the elements to drop in that area, what they'd be called, etc.

    Sorry if this is a dumb question, I just seem to be missing that part! Thanks for any help!!
  • you saved me hours of trying to figure this out. thanks for posting Bert!
  • Question(s) from a very tired mind at midnight - after reading, trying and re-reading this tutorial - and searching DIY forums multiple times.
    I want a non-static home page with three columns - and that's what I have. I would like to make all other pages 2 columns (main and sidebar_2). I am good with the existing sidebar_2 content.

    Can you please point me in the right direction?
    The site is at http://www.PartnersForHousing.com

    Thank you!
  • jek123
    This tutorial very very helpful to me! Сlearly not all, and accumulated a lot of questions for you...Required ask how they articulate.
  • Caesar
    So in the place where "your content goes here" where do you find the other thesis html content to place in that place. For instance I have created a home page with thesis that has its default setting 3 column layout. I set that for my static home page. Now I want the thesis default setting 2 column layout for every other page. But where do i find the actual html to copy and paste into the custom_functions.php so that the 2 column layout shows up?
  • travisreed
    How do you link blog posts to template so when you post a blogs from control panel/admin it posts onto the custom template? Sweet tutorial by the way.. =)
blog comments powered by Disqus

Previous post:

Next post: