Forums

[resolved] XHTML page template not working without PHP (8 posts)

  1. canchuckwood
    Member
    Posted 3 years ago #

    I'm trying to make a custom front page template which shows images as links as an index navigation. I'm using WordPress as a basic CMS for the news part of a band website.

    I've created a separate page template named front.php, and written the basic html and css code. However, nothing displays unless I include the php code from page.php underneath the html code. This means the header, footer, sidebar etc, are all displayed under my index navigation. I only want the image links to show, not the rest of it. When I remove any part of the php code it displays errors.

    URL is test.charlettehannah.com. (Excuse the site's messiness at the moment as I've only just started working on it, but you can see what I mean about the index image.)

    Thanks in advance for your help :~)

  2. vachi
    Member
    Posted 3 years ago #

    i am confused, you are building your own theme, is that correct?
    if you have any php code in a file the file extension has to be .php
    you do not have to display get_sidebar or header, please post your code too tx

  3. canchuckwood
    Member
    Posted 3 years ago #

    Sorry for the confusion!

    The file extension is .php. I started with the Kind of Business theme as I am new to wordpress, and am customising it.

    The code for the file is
    [long code moderated - use a pastebin service]

    But if I remove any of the php code in the second half of the file, nothing displays, not even the html and I can't figure out why.

  4. canchuckwood
    Member
    Posted 3 years ago #

    Longhand CSS for the html is:

    And works fine on my computer by itself not in wordpress.

    [long code moderated]

  5. Evita
    Member
    Posted 3 years ago #

    I think, following code would be correct:

    <?php
    /*
    Template Name: Front
    */
    ?>
    <?php get_header(); ?>
    <div id="content">
    <div id="index-container">
    
    <div id="man-container"><a class="man" href="http://www.test.charlettehannah.com"></a></div>
    <div id="wheel-container"><a class="wheel" href="about.html" /></a></div>
    <div id="windmill-container"><a class="windmill" href="gallery.html" /></a></div>
    <div id="cart-container"><a class="cart" href="music.html" /></a></div>
    <div id="words-container"><a class="words" href="lyrics.html" /></a></div>
    <div id="globe-container"><a class="globe" href="contact.html" /></a></div>
    <div id="cap-container"><a class="cap" href="links.html" /></a></div>
    <div id="wood-container"><a class="wood" href="buy.html" /></a></div>
    <div id="spin-container"><a class="spin" href="journal.html" /></a></div>
    <div id="horse-container"><a class="horse" href="poems.html" /></a></div>
    
    </div>
    
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Now select this page as your frontpage in your dashboard. Your extra styles comes in the style.css in your theme folder.

  6. canchuckwood
    Member
    Posted 3 years ago #

    Thanks Evita :~) What I'm really after is just the html, as in, I don't want the header and sidebar and footer on the index page at all. Ah well, back to grindstone!

  7. Evita
    Member
    Posted 3 years ago #

    Well, some kind of header and footer you will need for the site. So create a new header.php, eg. header2.php (and the same for your footer), save both in your template folder and include them in the front.php with this code:
    <?php include (TEMPLATEPATH . '/header2.php'); ?>
    This code goes instead of <?php get_header(); ?> (same place).

  8. canchuckwood
    Member
    Posted 3 years ago #

    Ah ok, so it needs a header and footer to display. Thanks so much! Will get cracking.

Topic Closed

This topic has been closed to new replies.

About this Topic