I don’t know if this is a quirk of WordPress 2.6.2 or if something has changed in recent versions that aren’t reflected by the WordPress documentation, but I’ve had a hell of a time setting up a custom front page and shifting the blog index off to its own directory (like example.org/blog/). If anyone else is having a problem with 2.6.2 and custom front pages, this could help you…
In case it matters, I’ve got WordPress installed in its own directory and the site is using a custom theme.
To create a custom front page, you can use the
is_front_page() conditional in the index.php theme file:
<?php if ( is_front_page() ) : ?> <h2>My front page</h2> <?php else: ?> <h2>Other templates</h2> <?php endif; ?>
To create the blog index at /blog/, you need to create a dummy page called “blog”. You should be able to create a template for that page as the blog.php theme file. For some reason, my WordPress installation is not picking up the blog.php theme file, as it should according to the documentation. Without that file, it wasn’t falling back to index.php as I expected either. The latter observation I realised to be my own stupid fault as I had a page.php theme file that was being picked up by WordPress and used for my blog index. Still, blog.php should override the page.php file and it isn’t.
So, I’m currently using page.php for the blog index, detecting it using
<?php if ( is_page('blog') ) : ?> <h2>My blog index</h2> <?php else: ?> <h2>Other page templates</h2> <?php endif; ?>
If you don’t have page.php in your theme, WordPress should fall back to using index.php. As mentioned above, you can detect the front page in there using
is_front_page(), but you should also be able to detect the blog index in that file using
<?php if ( is_front_page() ) : ?> <h2>My front page</h2> <?php elseif ( is_page('blog') ) : ?> <h2>My blog index</h2> <?php else: ?> <h2>Other templates</h2> <?php endif; ?>
I hope this helps someone else out there.