WordPress.org

Ready to get started?Download WordPress

Forums

Template Default Question (5 posts)

  1. digne
    Member
    Posted 4 years ago #

    I've been creating a theme from another theme. I'm designing it for a friend but I have been testing it on another site before applying it to my friend's site. I've got almost everything done that I need done but I'm having trouble with some of the defaults.

    My friend's website: http://www.elizabethhanbury.com/ defaults to a page rather than to her blog, the links in the sidebar have a "home" link that links back to http://www.elizabethhanbury.com/. The page is editable in the pages section.

    To redesign the index I added a home.php template to the theme. I have created a "home" page in the pages section, but the two do not link together. When ever I add the WordPress Loop to the home.php file it calls blog posts and adds them to the page. I've search all over my setting and her settings to see if there is something I'm missing but no. How do I get the content in the "home" page to default into the home.php file?

    I'm working on the theme here: http://sheynawatkins.com/wordpress/

    I don't have the WordPress Loop in the file at the moment but you see how my link to my "home" page in the sidebar links to a whole other page.

    I'm using: WordPress 2.3.3
    My friend is using: WordPress 2.7

    2.3.3 is what my web host had available. I'm going to update as soon as I figure out how. My web host didn't have things set up the way WordPress expects you to set things up.

  2. @mercime
    Volunteer Moderator
    Posted 4 years ago #

    defaults to a page rather than to her blog,

    Check if the theme to that original site has a home.php OR if in its Admin > Settings > Reading, "Front Page Displays" > A Static Page with a specific page for the home page. To get it back to blog form, just reset the Reading Panel to "Front Page Displays" > Your latest posts.

    I added a home.php template to the theme. I have created a "home" page in the pages section, but the two do not link together.

    They won't link together. You should check out codex re Template Hierarchy wherein:
    If a visitor goes to your home page at http://example.com/, WordPress first determines whether it has a static front page. If a static front page has been set, then WordPress loads that page according to the page template hierarchy. If a static front page has not been set, then WordPress looks for a template file called home.php and uses it to generate the requested page. If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page.
    Therefore if you want to create a special template page for a home page using Pages, do not name it home.php. If you want to set up and upload home.php, do not create a static front page named Home. Use one or the other method.

  3. digne
    Member
    Posted 4 years ago #

    Well that stinks!

    So I'll probably have to leave everything in the home.php file. Which will make it harder for my friend to edit herself.

    If I knew the file path to the pages files, could I do an include or require in php? Probably not, WordPress would probably try to create duplicate pages one using home.php and another using index.php.

    So now I need to find out how to edit the php in the sidebar to including a link back to the "home" page now that it will no longer be in the "pages" section WordPress won't automatically generate one.

    Can any one help me there?

  4. @mercime
    Volunteer Moderator
    Posted 4 years ago #

    What I posted above was that you have to use one or the other method. So you have option of either
    1) a home.php which will automatically be the home page OR
    2) us a Page set as Home page in Setting > Reading > Front Page is ...
    And that Page can either be:
    a. a regular Page or theme's page.php OR
    b. Page template created (you can call from Page > Add New > Attributes box) named page-home.php

  5. digne
    Member
    Posted 4 years ago #

    I understand that. But I'm going to need a link back to my home page now that WordPress won't automatically create one. My PHP reads as follows:

    <ul>
    <?php
    
    // for sidebar widgets
    if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( ) )
    {
    
        // search bar
        sp_sidebar_open( "searchbar", "<h2>Search</h2>" );
        include (TEMPLATEPATH . '/searchform.php');
        sp_sidebar_close( );
    
        // pages
        sp_sidebar_open( "pages", "<h2>Pages</h2>" );
            echo '<ul>';
            wp_list_pages("title_li=&sort_column=menu_order&class=");
            echo '</ul>';
        sp_sidebar_close( );
    } // sidebar widgets
    
    ?>
    </ul>

    I've tried the following code to add a real home link in but it just causes all the image links of the page to flicker when the mouse is over them and doesn't add the link I want.

    <ul>
    <?php
    
    // for sidebar widgets
    if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( ) )
    {
    
        // search bar
        sp_sidebar_open( "searchbar", "<h2>Search</h2>" );
        include (TEMPLATEPATH . '/searchform.php');
        sp_sidebar_close( );
    
        // pages
        sp_sidebar_open( "pages", "<h2>Pages</h2> <ul><a href=\"http://www.elizabethhanbury.com\">Home</a></ul>\n" );
            echo '<ul>';
            wp_list_pages("title_li=&sort_column=menu_order&class=");
            echo '</ul>';
        sp_sidebar_close( );
    } // sidebar widgets
    
    ?>
    </ul>

    See:
    http://sheynawatkins.com/wordpress/

Topic Closed

This topic has been closed to new replies.

About this Topic