Build Your Own Business Website header image

Troubleshooting Thesis Custom Templates – Part 4 – Apply to Multiple Pages

Difficulty Level -

Filed Under Topics - ,

Listed Under Lesson Subjects -

Applies to -

The member wants to make his custom template apply to multiple pages. We discuss how to use a conditional statement with multiple page ids to accomplish this. An example of such code is provided below. The code below demonstrates how to create a single function that applies multiple custom templates to multiple pages:

Select the link below to watch a high definition version of this video

[S3VIDEO file=’public/liveanswers/LA12-20-10a1-custom-templates-part4.mp4′ bgimage=’https://www.byobwebsite.com/wp-content/uploads/2011/02/LA12-20-10a1-custom-templates-part4.jpg’ displaymode=’overlay’]

Code Used In This Answer

/*********************************************************************************************
* This assigns customization based on the page.
*********************************************************************************************/
remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');

function byob_custom_pages(){
    if (is_home()){
        home_page_customization();
    }
    elseif (is_page(array(57, 70, 120, 148, 194, 237, 324, 353, 471, 497, 540, 641, 690, 722))){
        add_action('thesis_hook_custom_template', 'lesson_page_customization');
    }
    elseif (is_page(array(788, 2480 ))){
        add_action('thesis_hook_custom_template', 'member_page_customization');
    }

}
add_action ('thesis_hook_before_html', 'byob_custom_pages'); 

Video Transcript

Okay so a couple of questions come up. How do I put multiple page numbers in there like separate them by a comma, a colon, semi-colon…how do I do that? That’s the first question. And the 2nd question after that, well we can do that question first but I have another question as well.
Okay so the way that works is that you need to use a piece of code… you don’t just put numbers after it. Actually what you have to do is you have to do it as an array. And so for example, I have a great example of this where I’ve sort of taken it to the extreme where you say… you know, it is page array and it’s all of these numbers. You know, each one of these is a page id and you just wrap it if this page has its own opening and closing parenthesis. In fact, I could just shorten it just so that’s… actually, here’s a good example right below. If it’s page array and then it’s 788, or 2480, that’s what this looks like. I will just for grants, I’m gonna go ahead and copy that code for you and email it to you so you have an example. You know, I wish there was a way of sort of adding text chat back and forth but there doesn’t really appear to be with this system so compose a piece of there for you and send it off.

0 Comments… add one
0 comments… add one