• Hey guys!
    I created a couple of pages from the WordPress back-end; these pages use the “page.php” template by default. However, I wanted to have them use a different template say, like this:

    <?php
    /*
    Template Name: My Custom Page Template;
    */
    ?>

    The above code WORKS!! which is good. Here’s my problem though:
    I know that the homme page uses the default template “index.php” or “home.php” if you assign one. However, I want my home page to use this template,

    <?php
    /*
    Template Name: My Custom Page Template;
    */
    ?>

    Thanks for your help!!

    My wordpres pages don’t use the assigned custom templates

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why? There’s only one home page, so use home.php.

    If you check out the WordPress Template Hierarchy you will see that custom pages are not in the hierarchy for the home page.

    Cheers

    PAE

    Thread Starter crazytuts

    (@crazytuts)

    I can’t even understand the template hierarchy but I will look that up on Youtube.
    Thanks a great deal for your comment though, that helps some.
    Just one other question:
    When you build WP themes, do you most of the times, use the default template for most pages, and only customize your home page with the following:

    <?php
    /*
    Template Name: Home Page;
    */
    ?>

    ?????
    secondly, when you do use the above template for your home.php page, do you use static content? That is do you put most of your html in the actual home.php page in its folder saved on your local computer, OR do you put that html content in the wordpress box for pages?

    Thanks again Peredur!

    In my case, I very rarely create custom page templates. I’ve never found the need. But then again, I hardly ever create full themes. I just create a child theme based on some other theme where somebody else has done most of the heavy lifting and so I don’t have to create every template for every situation from scratch.

    This saves me work and my clients money.

    But even for a full theme, the standard templates are usually the only ones necessary. Custom templates are, I believe, really for one-offs that cannot be thought of any other type of page; i.e. not just for cosmetic differences that can be sorted using the page types in the Template Hierarchy.

    As to your second question I’m not sure what you mean by the “above template”. If you want WP to display a page according to the home.php page then all you have to do is to make that page your site’s home page in your WP Dashboard. It’s not a custom template and it doesn’t need any special comments block at the top.

    And as for using static code, I guess it depends on what you want, but on the whole, no. You’d call at the very least things like get_header() and get_footer() and probably get_sidebar(), and you’d use WP functions to get the dynamic content. After all, what’s the point of using a CMS if you’re going to hard code the content? You want to be able to edit the home page content (for example) in the WP Dashboard editor, don’t you.

    HTH

    PAE

    Thread Starter crazytuts

    (@crazytuts)

    I agree with you, that would be the point of using a CMS. I was going to hard code my home page but I get what you’re saying.
    Also, I haven’t gotten to the point of building complete themes yet, I build child themes based on blank themes coded by somebody else just like you. But I hope to expand my curiosity to building full, functional, working themes.

    I think the big struggle I have so far in building these themes is understanding the WP page hierarchy but I’ll read the link you sent me earlier and get some other resources from youtube.
    I only get what the main template do, but beyond that I am lost! For instance: pages use page.php, single posts use single.php a blog home page that displays a list of all post would use a default template or custom one. And index.php and home.php are interchangeable I guess.

    Basically, I get the core idea of how these WP templates work, but need to step back and dive into template hierarchy a little deeper.

    Thanks a lot for your great response once again Peredur!

    crazytuts!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Homepage and pages aren't working with assigned template!’ is closed to new replies.