Continuing from Part 1 at NETTUTS, we take a look at some of the features of the GamePress theme for sale on ThemeForest for $40.
GamePress is a “Gaming News & Reviews” theme for WordPress and currently one of the most popular themes at ThemeForest (at only $40). It is a very advanced theme and really pushes what the WordPress engine can do!
Single Posts
For GamePress, I had to use multiple single post templates depending on what category the post is in. For example, a normal post will display like so:

However a Review/Preview needed its own layout to display a ‘Review Summary’ section:

Since WordPress does not include native support for multiple single-post templates, a small workaround was needed:
<?php
$post = $wp_query->post;
if ( in_category("$gp_reviews_cat") ) { // Reviews
include("single-reviews.php");
} elseif ( in_category("$gp_previews_cat") ) { // Previews
include("single-previews.php");
} elseif ( in_category("$gp_features_cat") ) { // Feature
include("single-feature.php");
} else { // News
include("single-news.php");
}
?>
The above code was placed in the single.php file. It simply checks whether the post belongs to a certain category. If it does, the corresponding single-post file is loaded. Note that it checks for four categories: Review, Preview & Feature and finally anything else will use the default ‘news’ template.
This code is also very useful for WordPress-powered portfolios where separate layouts are needed for a portfolio item and a blog post.
Theme Options
GamePress comes with an ‘Theme Options’ page accessible via the Dashboard which houses 38 options for customizing the theme:

Multiple Stylesheets
By popular demand, a ‘White’ version of GamePress is included which can be selected via a checkbox on the Theme Options page:

In order for WordPress to know which stylesheet to load, I used the following code in the header of the theme:
<?
if ($gp_stylesheet == "true") { ?>
<link rel="stylesheet" href="<? bloginfo('template_directory'); ?>
/style-l.css" type="text/css" media="screen" />
<? } else { ?>
<link rel="stylesheet" href="<? bloginfo('template_directory'); ?>/
style-d.css" type="text/css" media="screen" />
<? } ?>
$gp_stylesheet refers to the checkbox on the options page. If it is checked it will return “true” and thus load the White stylesheet (style-l.css). Otherwise, the default Dark stylesheet will be used.
Feel free to re-use this code for your own theme. Alternatively, you could use a drop-down box if you’re planning to provide more than two stylesheets.
Archives Page

This Page Template displays everything, regardless of category in a chronological order. To replicate this, you can use the following code:
<ul class="archives">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("paged=$paged");
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a> <span><?php the_time('F j, Y'); ?></span></li>
<?php endwhile; ?>
The $paged line will allow the results to display over multiple pages (Read More).
And the accompanying CSS:
.contentblock ul.archives li {
list-style: none;
padding-bottom: 10px;
margin-bottom: 10px;
overflow: hidden;
border-bottom: 1px dotted #3a3a3a;
}
.contentblock ul.archives li a:link, .contentblock ul.archives li a:visited {
float: left;
}
.contentblock ul.archives li span {
color: #545555;
float: right;
font-size: 0.9em;
}
Thanks for reading. Look out for more WordPress-related posts here each week!





Jauhari
October 21st, 2008
I love the Single Page hacks
Daniel K
October 22nd, 2008
IIRC you can also do the single pages as “category-#.php” and it will pick it up.