Hacking WordPress

So this is my first WordPress post. But if I did a good job matching it to my old Movable Type stylesheet, things should look pretty much the same (although I haven’t updated the templates for any of the pages besides the main page, so the archives, etc. are still a bit ugly).

Something I was looking forward to with WordPress was using it for managing all the pages on toppa.com. But I immediately ran into trouble when I discovered that, in order to do this, you have to install WordPress at the top of your web docs directory (which makes sense), and you can’t have the main page be named anything other than index.php. This was a potential show-stopper, since I’m not about to give up my uber-cool custom homepage for a same-as-everyone-else’s blog page.

I found a discussion thread on this, but the hidden option to change the filename they mentioned has been removed in the latest release of WordPress. It’s no longer a variable in the database, and they didn’t even have the decency to make it a variable in the code. Instead, the code alternates between hard-coded references to index.php, or it just assumes the default index file of the install directory. Lame.

But I like all the other aspects of WordPress enough that I decided it was worth a bit more investigation. First I thought of making a symlink, but I don’t have shell access to my site, and the FTP server is configured with a restricted set of SITE command options that doesn’t include symlink. So this is what I ended up with:

  • My home page is at /index.html
  • My blog page is at /index.php (fortunately the server is configured to give precedence to index.html)
  • I added the following to my root .htaccess file:
    RewriteEngine On
    RewriteRule ^blog(.*) /index.php$1 [R=301,L]

    Since WordPress builds all it’s dynamic pages by relying on arguments to index.php, this redirect won’t drop query string arguments. I just have to be careful not to create any directories that start with the word “blog.”


  1. Reply
    PatW February 25, 2005

    Heh I get to be the first WP comment. I was going to suggest the index.html trick. I use that alot for temporary homepage overrides on the Lavajet site. Otherwise There is a way to setup mod_rewrite so it will only rewrite if the file doesn’t exist so basically as long as you have a file that exists it won’t run it through index.php (you want to rewrite through index.php for the clean URLs anyway). Let me see if I can dig the if file exists conditionals for mod_rewrite.

    I would think you would be able to keep your homepage as index.php by using the theme system, since one of teh big advantages that 1.5 added in that everything no longer has to run through index.php (one of the reasons I went with Textpattern at the time was the sections implementation it has). Here is the wiki on theme development http://codex.wordpress.org/Theme_Development which might help with tackling that.

  2. Reply
    PatW February 25, 2005

    hmmm following up my own comment. It seems that can implement a page.php template that will be called when a “page” entry is called. You could make that template completely bare and basically construct your whole html in wordpress that way you have a generic template that can be used for “static” pages. Not sure if there is a page.php per category (which would be shame becaue I can see wanting static pages to look different in different areas of the site.)

  3. Reply
    John Speno February 28, 2005

    Your RSS path changed too. You gots to warn people about that in the old RSS file, the one
    we subscribe too, before you switch or else we might forget about you.

    Also, this new comment textarea doesn’t wrap long lines. Me like wrappy.

  4. Reply
    John Speno February 28, 2005

    btw, no shell access? who’s your provider? i can’t live w/o root (or a fake root like I have at westhost.com).

    arg. no wrapping! 🙂

  5. Reply
    Mike February 28, 2005

    I give you wrapping! I had to track down the right XHTML way to do it: style=”overflow: auto;”

Leave a Reply