August 13th, 2006
How to Put Up a Custom Front Page in WordPress
Before we start on the meat of the Using WordPress (WP) as a CMS series, there’s some fundamental technical stuff we have to get out of the way first. First on the list is: Custom front/main/index pages.
What For?
By default, WordPress’ front page displays a reverse chronological list of your posts - with whatever extras you chose to add, e.g. Recent Comments, Flickr, etc. This is the normal blog index, and is normally the first thing you want to “get rid of” if you want to use WP as a more web site-ish CMS. For example, you might want your front page to display only an introduction and a sitemap, or just a simple Flash movie.
But at the same time, you might still want to have a normal blog index somewhere for the blog aspect of your web site. So, how do you get yourself a custom front page while still having the normal blog index alive and kicking somewhere else on site?
Three+ Ways to Do It
These are not comprehensive (I’ve not touched at all on manually modifying your rewrite rules here), but I believe that they are all you need. Correct me if I’m wrong though.
- WordPress’ Default: home.php
WP’s template hierarchy is setup such that ahome.phptemplate file is always checked before calling theindex.phptemplate file in your theme directory. So, all you need to do to overrideindex.php, i.e. the normal blog index, is to create ahome.phpfile in your theme directory (since most, if not all, themes don’t have it). Thishome.phptemplate will house the code for your custom front page, and will generally be laid out like this:
<?php
/*
Template Name: Home
*/
?><?php get_header(); ?>Your Custom Front Page Content (e.g. Flash movie, site map) Here!!!<?php get_footer(); ?>That’s it for your custom front page. Now, for your normal blog index, you’ll have to create a page named “Blog” (the name doesn’t matter actually, but the post slug should reflect the directory you want your blog to be in, whether it is “blog”, “journal” or “whatever”, e.g. http://yoursite.com/blog/), as well as a custom page template for it. The template’s name is unimportant, but for consistency sake, I suggest naming it
blog.php. Its contents should look something like this:<?php
/*
Template Name: Blog
*/
?>The content here should mirror your original blog index (index.php), with whatever changes you have given it.Last but not least, change the permalink structure of your blog posts in Options >> Permalinks. If it was just
/%postname%/before, then change it to/blog/%postname%/. This way, URL-wise, all your blog posts will come under your normal blog index, e.g. http://yoursite.com/blog/post-title/.You may also want to change the permalink structure of your categories by adding an additionalEdit: Oops, since we applied a static prefix (i.e. /blog/) to our blog entry permalink structure, archive permalinks are automatically adjusted to match, e.g. http://yoursite.com/blog/category/category-title/./blog/prefix. This way, the URLs of your categories will match your posts, e.g. http://yoursite.com/blog/category/category-title/.
Note: Theis_home()test will apply only for your custom front page. So, to test for your newly-created normal blog index, useis_page('blog')instead. - Variant of Approach 1
You might have noticed that the use ofhome.phpabove is somewhat redundant since the originalindex.phpends up totally unused. So, instead of creating both a home.php and ablog.phpfor your custom front page and normal blog index, respectively, you can just create ablog.phplike above, and useindex.phpfor your custom front page.
The advantage of using
index.phpinstead ofhome.phpis that you retain your higher-priority (hierarchy-wise)home.phptemplate for future uses. For example, you might some day want to evaluate some conditionals before loading your front page. Instead of having to place these conditionals in yourindex.php, you can get them to run beforeindex.phpis even loaded by placing them in yourhome.php. However, the same end result can usually be achieved whether you usehome.phporindex.php. Most of the time, your choice boils down to the so-called “elegance” in method. - Using the Filosofo Home-Page Control Plugin
This is probably the easiest solution out there (which BTW you should already be downloading). What the plugin does is to allow you to choose any page you’ve created in WordPress as your custom front page. Of course, you can choose to use the WordPress Default, i.e. if exists,home.phploads first, thenindex.phpdoes. If you do choose any arbritary page in WordPress, you may want to use a custom page template for it. The contents of that template should be laid out the same way as inhome.phpin the first approach above.
The second thing it does is to save you the hassle of having to create another page and its page template (blog.php) just for your normal blog index. All you have to do is to specify the directory you want your blog index into be in, e.g.blog, and your originalindex.phpwill automatically be loaded when someone goes to http://yoursite.com/blog/.
And to think all this is done in the comfort of your WP admin panel, in Options >> Home-Page Control. But like the first approach and its variant, you’ll still have to modify the permalink structure of your blog entries at Options >> Permalink. It’s done in the same way.
Note: Like just now, the
is_home()test holds only for your the page you choose as your custom front page. But for your blog index, use the!is_home() && !is_page && !is_archive()test. The plugin author suggests using just!is_home() && !is_page, but for some reason, I find that my category and dated archives also satisfy those test parameters. - Using the Static Front Page Plugin
Although the plugin used here is different, the approach is mostly similar as the previous one. The only practical difference is in the implementation of the normal blog index.
Unlike the Filosofo plugin, you will still have to go through the hassle of creating a page (named “Blog”) and custom page template (namedblog.php) for your normal blog index - just like in the first approach. Remember to change your permalink structure as well.
Alternatively, you can follow the instructions of the plugin creator: Create a category named “blog”, stuff all your posts into that category, then use the resulting category page as your normal blog index. You can even customize the look of that specific category to distinguish it from your other categories (by creating a custom category template such as
category-6.phpif the category had an ID of 6). But the problem with this approach is that there doesn’t seem to be a way to get a proper permalink structure (i.e. your normal blog index at http://yoursite.com/blog/ and your blog posts at http://yoursite.com/blog/post-title/) without touching your rewrite rules.
Conclusion
I’m in favour of using the Filosofo Home-Page Control plugin approach, but frankly, any one of them will do. Try to get at least one of the approaches in your repertoire though because I won’t be repeating the stuff here when I start on the real content of the Using WordPress as a CMS series.
Edit: Added in consideration for the permalink structure of categories. I forgot that archive permalinks are automatically adjusted to match your new blog index location if you applied a static prefix.
If you found this post useful, keep updated with future posts by subscribing to blogHelper (for free) through RSS or email.















26 Comments
August 13th, 2006 at 10:05 am
[…] How to Put Up a Custom Front Page in WordPress […]
August 13th, 2006 at 3:43 pm
Nice Tip
i did something like that but simple PHP way and didn`t work with the Titled urls “PermaLinks” so i used Static Home Page Wordpress Plugin.
Hamza
August 14th, 2006 at 7:03 am
Ah, yes. I forgot to mention that as an advantage of the Static Front Page plugin. Thanks for reminding me.
August 14th, 2006 at 7:35 am
[…] Contact How to Put Up a Custom Front Page in WordPress […]
August 18th, 2006 at 5:51 am
[…] Now that we’re done with a large portion of the technical basics of Using WordPress (WP) as a CMS, let’s continue on with the next step: Using WP for a portfolio site (primarily graphics and design-based). […]
August 23rd, 2006 at 10:18 pm
Some good and interesting content
August 29th, 2006 at 10:20 pm
[…] How to Put Up a Custom Front Page in WordPress | blogHelper (tags: wordpress tutorial) […]
September 13th, 2006 at 1:05 am
speaking of customising the frontpage: how did you solve your nifty DHTML-title-only display on your frontpage? is that a plugin, too? or your own hack?
September 13th, 2006 at 1:28 pm
Very nice list, thank you!
But I’m still waiting for a decent german version …
It seems the only way to have microformats right now on a german blog is to create the code using one of the generators and then pasting it into the Wordpress-Editor.
Hello Helge, btw
September 14th, 2006 at 11:36 am
helge: The implementation I’m using utilises the lightweight moo.fx Javascript library, as described briefly here. I’m not sure whether there’s a plugin for this.
But there are plugins for AJAX implementations - which are more advanced than mere moo.fx. They generally involve greater script file sizes, plus some other usability considerations - though AJAX certainly does have its own advantages. It’s up to personal choice really.
September 14th, 2006 at 11:39 am
Japhy: Aiks, wrong post.
But anyway, I’m afraid that I’m not familiar with non-English microformat implementations. When you say that the plugins are not compatible with German blogs, are you referring to problems with accented characters?
September 17th, 2006 at 8:30 pm
Thanks for the great info on this site. One question: When creating a static homepage and changing the permalink structure, how will that affect existing incoming links to the site?
September 21st, 2006 at 11:37 pm
An interesting home page solution would be to change the index.php to show the “last posts” grouped by category, as some news portals do.
So one can have “boxes” of news of different themes: health, technology and so on. In this way a user interested only on one type of news can focus on “his” box and the go forward in reading news of that category.
Some time ago I’ve tried to discover how to make such a thing, but… I failed :-).
September 25th, 2006 at 5:58 am
[…] Update: be sure to check out bloghelper’s tutorial on the same subject which offers more in-depth details and a few more alternatives. […]
October 1st, 2006 at 2:40 pm
[…] Nota: Questo articolo è la traduzione in italiano di How to Put Up a Custom Front Page in WordPress il quarto di una serie di post pubblicati su blogHelper che spiega come trasformare WordPress in un sistema di gestione di contenuti. La traduzione viene pubblicata qui con il permesso dell’autore: Ang Zhuu Ming. […]
October 19th, 2006 at 8:07 am
[…] So I did some more research on using WordPress as a CMS, and I bumped onto this article in BlogHelper, on How to put a custom front page in WordPress. The article presented several different methods of doing it, and being the lazy me, I chose the easiest way out , that was to download the Filosofo Home Page Control plugin, that practically does everything for you. […]
October 31st, 2006 at 2:25 pm
I’m a little new to Wordpress, but not entirely, and I’m afraid I’ve missed some important point.
“create a page named “Blog” …, as well as a custom page template for it.”
I created a page named “News”, and I believe I copied my original index.php to news.php. I thought this would give me the list of recent “News” entries, but I get my News Page content, instead.
Can you clarify this point for me?
Thanks, Steve
January 13th, 2007 at 6:54 am
[…] Nota: Questo articolo è la traduzione in italiano di How to Put Up a Custom Front Page in WordPress il quarto di una serie di post pubblicati su blogHelper che spiega come trasformare WordPress in un sistema di gestione di contenuti. La traduzione viene pubblicata qui con il permesso dell’autore: Ang Zhuu Ming. […]
March 28th, 2007 at 10:29 am
[…] Ci sono modi e modi di mostrare un homepage, ma senza spaccarsi la testa cambiando nome ai files, ecc… E’ possibile usare il Filosofo homepage plugin che permette di selezionare una qualsiasi delle pagine create in WP come homepage senza troppi sbattimenti. […]
May 23rd, 2007 at 1:23 am
WordPress version 2.1 and newer includes the possibility to select the page to be displayed as front page. You can access them under Options > Reading.
July 24th, 2007 at 4:09 am
[…] http://bloghelper.is-there.net/how-to-put-up-a-custom-front-page-in-wordpress/ […]
August 21st, 2007 at 7:20 am
[…] measure this uncanny examination at http://bloghelper.is-there.net/how-to-put-up-a-custom-front-page-in-wordpress/ about […]
August 25th, 2007 at 8:32 am
thanks for this, really solved a major problem i was having with WP
January 20th, 2008 at 11:52 am
Static Home Page Wordpress Plugin is a stroll!
March 2nd, 2008 at 3:23 am
[…] 2 אנחנו מתחילים את מסע הלמידה בעיון במדריכים (1, 2 3, 4, 5|ווידאו). ישנם גם לא מעט תבניות ופלאגינים שעושים את […]
May 12th, 2008 at 10:33 pm
[…] How to Put Up a Custom Front Page in WordPress | blogHelper […]
Leave a Reply