WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Trouble with creating custom template (8 posts)

  1. dkbg
    Member
    Posted 9 years ago #

    Okay, I've installed WordPress 1.5. I've added posts and viewed them using the default theme perfectly. The trouble starts when I try to create my own template using WP functions.

    I have a site design which I've been working on but is not yet complete, and I wanted to try to figure out how to get the blog working before I continue. I've inserted all the include functions for header, footer, etc. into index.php and I've used the loop (or attempted to anyway) to try and display the two posts which I've written along with some other tags for displaying various bits of info like a permalink and the date.

    The problem is that when I view it, nothing appears. The screen is blank and the source is simply "<html><body></body></html>" (which differs from Firefox's default which includes a doctype...if that helps any). Now this question may have already been answered, but I've used the search and I've been poring over the wiki documentation, and though my knowledge of PHP is limited, I've done my best to figure out what I'm doing wrong.

    I'm pretty sure it has to do with the PHP I've inserted and having done that incorrectly. Any information would be much appreciated.

    Here is my site

    Here is the code of my index.php file:


    <?php define('WP_USE_THEMES', false); ?>
    <?php get_header(); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="post">
    <h2><?php the_title(); ?></h2>
    <p class="postdata">
    <a> rel="bookmark" title="Permanent Link to "<?php the_title(); ?>">Read it all...</a>
    <span>Placed in<a href="#3434"><?php the_category(', '); ?></a></span>
    <span class="date">
    <span class="month"><?php the_time('M'); ?></span>
    <span class="day"><?php the_time('j'); ?></span>
    <span class="time"><?php the_time('g:i a'); ?></span>
    </span>
    <?php the_content(); ?>
    </div>
    <?php endwhile; ?>
    <?php
    get_sidebar();
    get_footer();
    ?>

    P.S. Where am I supposed to put the .htaccess file in my site's directory structure? The root? The wordpress folder? Alongside my blog's files?

  2. tomhanna
    Member
    Posted 9 years ago #

    Do you have this at the top of your index.php (the main one, not the one in the template folder)?

    <?php require('./wp-blog-header.php'); ?>

  3. vkaryl
    Member
    Posted 9 years ago #

    The .htaccess file goes in the wordpress root - that is with the files such as wp-config.php, wp-blog-header.php, etc.

  4. dkbg
    Member
    Posted 9 years ago #

    I did not have that line tomhanna. Was I supposed to? I've since added it but there has been no change, if I was supposed to have it.

  5. tomhanna
    Member
    Posted 9 years ago #

    It's supposed to be in there.

    Why are you setting WP_USE_THEMES to false?

    The include tags which you are using (get_header, get_footer, get_sidebar) pull the header, footer, sidebar, etc. from the active theme directory.

  6. dkbg
    Member
    Posted 9 years ago #

    I was under the impression that I was supposed to do this to use my own template. I probably misinterpreted the documentation I read. Oh? I guess I've totally misunderstood the documentation on the include functions then...which should I be using instead?

  7. tomhanna
    Member
    Posted 9 years ago #

    Where are you putting your template files? If you make a folder for your theme in /wp-content/themes/ then you can use it just like any other theme.

  8. dkbg
    Member
    Posted 9 years ago #

    Okay, I've finally figured it all out. It was all to do with the fact that I wasn't using the right directory for my theme, I had to fix up the code of my index.php file a bit and insert a function for my css file. Thanks for the help you've offered as it really helped point me in the right direction to make everything work.

    I realised that I should have been looking over the default theme files to figure out how everything is supposed to work, using these files helped me a lot as well.

Topic Closed

This topic has been closed to new replies.

About this Topic