WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Calling php onto a static page (10 posts)

  1. Christiaan
    Member
    Posted 8 years ago #

    I'm trying to setup a splash page at /index.html (while my WordPress files reside at /blog )

    I've been following the instructions on http://codex.wordpress.org/Creating_a_Static_Front_Page

    But I can't even get started. I put the following text only in my root index.html file:

    <?php define('WP_USE_THEMES', false);
    require('blog/wp-blog-header.php'); ?>

    But all I get is a blank page (as of writing this):
    http://last-straw.net/

    Any pointers?

  2. thegreatnorth
    Member
    Posted 8 years ago #

    Try renaming your file from index.html to index.php
    PHP can't run in a html document without some type of special server and htaccess settings.

  3. Christiaan
    Member
    Posted 8 years ago #

    Still get a blank page. And not only that if I try to view the page source of /index.php in my web browser it appears blank, when it's not as far as my FTP app and Dreamweaver are concerned.

  4. kickass
    Member
    Posted 8 years ago #

    The "creating a static front page" instructions are meant to make a WordPress Page become the homepage of the blog portion of your website. However, if your blog doesn't reside in your toplevel directory it can't "create" the index page of your site unless you do some .htaccess magic or somesuch.

    What you CAN do is call in parts of your blog into your static homepage. Instructions here:
    http://wordpress.org/support/topic/45242

    See it in action here, in the right side column:
    http://kickasswebdesign.com

    One caveat-- if you're already indexed in the search engines for yourdomain.com/index.html and you change the page to yourdomain.com/index.php you will LOSE your SE ranking. There is a way to change the .htaccess so that php will be recognized in pages that have .htm and .html extensions. If the site is new and not really recognized yet it won't matter.

  5. Christiaan
    Member
    Posted 8 years ago #

    Still get a blank page. kickass, the thread you point to doesn't appear to give different advice to what I've already done. Yes I'm trying to call parts of my blog to my root index page. I've tried this code, as per the thread you pointed to:

    <?php
    require_once("blog/wp-blog-header.php");
    define('WP_USE_THEMES', false);
    ?>

    But it's still showing a blank page??

  6. Nookster
    Member
    Posted 8 years ago #

    You need to set the php parser to be able to parse .html extensions. You do this by setting an Apache (or other server) handler to parse .html extensions with x-httpd-php

    For CPanelX:
    In the main admin area, go to "Apache Handlers". Then to add it, under "Extensions" type:
    .html
    ...then under "Handler" type:
    x-httpd-php
    ...then click Add of course and viola. All your html extension files will now be parsed by the php processor if there's any php code in them. I'm pretty sure this is what you're looking for. Hope it helps.

  7. Christiaan
    Member
    Posted 8 years ago #

    Thanks Nookster, do I still need to do this even if I'm using index.php as opposed to index.html

  8. goblue
    Member
    Posted 8 years ago #

    Is there any CODE on the root level index page? I mean, there has to be something there. Try putting something simple there for testing. ie (<h1>hello world</h1>). If that little PHP block you had on your page was all that was there, of course nothing will show!

  9. Christiaan
    Member
    Posted 8 years ago #

    Yes <h1>hello world</h1> works.

    This is indeed the only code I had on the page. I thought that was all I needed:

    <?php
    require_once("blog/wp-blog-header.php");
    define('WP_USE_THEMES', false);
    ?>

  10. jimisola
    Member
    Posted 7 years ago #

    I guess this issue is solved by now, but in case others find there way here I would like to point out that I believe that the reason why Christian had an empty page was because his require_once and define was in the wrong order. The default index.php for WP looks like this:

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    so in his case the following probably would have worked

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('blo/wp-blog-header.php');
    ?>

    a simple one would look like this:

    <?php
    define('WP_USE_THEMES', false);
    require_once('blog/wp-blog-header.php');

    get_header(); ?>

    <div id="page">
    <div id="content">
    Welcome to xyz.com
    </div>

    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic