Some template fixes

July 26, 2008

For a long while now, the meta data (posted date, number of comments, category, tags, etc.) have been missing from the posts index page at http://garyjones.co.uk/blog/ and I could explain why. I’d tried editing the “Main Index Template” plenty of times, but nothing was working.

I knew that WordPress had a number of fall-back templates, if certain files weren’t available, but wasn’t sure where to find this info, or how it could help.

My problem was two-fold: I’d got myself confused between the homepage of the site, and the homepage of the blog. Part of this template fall-back feature, is that WordPress checks for a {pagename}.php file before trying other templates. Unfortunately, I’d named the root homepage to home.php, but had set the Post Page to be Blog, but use this Home Page template to be the template of the Blog page! So confusing!

The solution was to have a read of the following, taken from the Template Hierarchy page, and then unscramble my file names, template names, assigned page templates, and the front page displays in the Reading Settings so that there was no confusion.

WordPress Template Hierarchy

Once this was done, then I could add in the correct meta data to the correct template, while not adding it to the root homepage. I still need to fill in the big blank space however…

I also added in the Popularity Contest plugin code – this is a percentage value of how popular the page is, compared to the most popular page, based on a score from permalink views, homepage views, feed views, comments etc. As the original plugin gives a fatal error in WordPress 2.6, I used a hacked version which works perfectly.

Now I’ve got a better idea of how the templates work, I can sort out the development area sometime in the future, so that the templates in use there are less scrambled too!

About the Author

Gary Jones

Gary Jones is a web developer from Basingstoke with a keen interest in anything to do with the web. He runs Gamajo Tech, a freelance web development company in Basingstoke, delivering sites and code professionally to small businesses and individuals.

Get social with Gary: Twitter | Facebook | LinkedIn | Last.fm

If you enjoyed this post, please consider leaving a comment and subscribing to the RSS feed or subscribing via email to have future articles delivered to your feed reader or email inbox.

{ 1 comment }

Gary December 17, 2008 at 02:30

This is the first reply.

Reply

Comments on this entry are closed.

Previous post:

Next post: