WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] home.php and the index.php that used to show... (7 posts)

  1. zagnex
    Member
    Posted 6 years ago #

    Hi, I am working on a website for a competition in my web design class (it's a website for the school's newspaper). Unfortunately, no one in the class even knows what PHP is, so I'm venturing on my own by using WordPress to manage the articles.

    Anyway, I needed a home page that can incorporate the use of The Loop so that I can obtain one article from certain categories as well as a straight up articles page with access to all of the articles.

    I figured home.php would be great, so I made my front page with the articles I want, but now I can't access what used to be index.php, which I need for the rest of the articles. I read how you should use the write page feature, but my home.php is somewhat different from the template that would be used if I wrote a page.

    Is there anyway around this? Thanks in advance.

  2. Kalessin
    Member
    Posted 6 years ago #

    If you're saying there's no link on your home page to the page with a list of posts on it, that's possibly because you didn't include the link on your home.php.

    Or, it's because the "blog" page hasn't been set. Have you created an empty Page and assigned it as the "Posts page" in Settings -> Reading?

  3. zagnex
    Member
    Posted 6 years ago #

    I don't think you understood my first post. I have a "splash page" in the form of home.php. I was hoping that after making home.php, I would still be able to access index.php because index.php has all of my articles. However, home.php seems to have overridden everything that leads to index.php.

    My question is: is there any way I can get back to JUST index.php without deleting home.php?

    Or, it's because the "blog" page hasn't been set. Have you created an empty Page and assigned it as the "Posts page" in Settings -> Reading?

    I just tried that, but the page I created (the url ends in "?page_id=43") is now also linking to home.php

  4. Kalessin
    Member
    Posted 6 years ago #

    Yeah, I didn't think I'd understood your first post, either :)

    I think the problem you're having is down to your creation of the file home.php. There are several file names that can be used instead of index.php, including home.php and default.php.

    This seems to be causing problems because WordPress is looking for yourdomain.com/?page_id=43

    WordPress assumes that its own index.php file is going to be called, but because you've got a home.php file, your server is actually serving

    yourdomain.com/home.php?page_id=43

    -- which is obviously not going to work.

    Try turning permalinks on. The .htaccess file this creates (if your directory is writable) will specifically force requests for directories and files which don't exist to index.php.

  5. zagnex
    Member
    Posted 6 years ago #

    WordPress assumes that its own index.php file is going to be called, but because you've got a home.php file, your server is actually serving

    yourdomain.com/home.php?page_id=43

    -- which is obviously not going to work.

    That's what I was thinking, but an individual post with the ending "?p=6" does, in fact, work.

    Is there anything I can do to change home.php to something else but still be able to use The Loop to call specific articles?

    Also, I tried changing the permalinks to "Month and Name", but that messed up my template and the horizontal navigation was put where the logo image should have been.

  6. zagnex
    Member
    Posted 6 years ago #

    Maybe someone else could shed some light on my problem?

  7. zagnex
    Member
    Posted 6 years ago #

    It turns out that I just had to use <?php require('./newspaper/wp-blog-header.php'); ?> on an index.php page that was outside of the wordpress directory.

    I'm so happy it's working now :)

Topic Closed

This topic has been closed to new replies.

About this Topic