Epic Theme Viewer
Written by Alex on July 15 2008
Listed under: Downloads, Plugin, WordPress

The New Theme Viewer
The beta versions and release candidates of WordPress 2.6 have a really cool new feature when choosing a theme to activate. A working version of the new theme is available in a thickbox, and I love this feature!

I decided to make a front end implementation of the themes.php page of the admin pages, and I modified a few files to do so. I have removed the activate links that you will find in the admin pages, and added some css to give the display some basic styling. This has only been tested on, and will only work on, Wordpress 2.6!

I have several directions that I want to take this in, but for the moment I have written a simple plugin that will create a display of all the themes in your wp-content/themes/ directory. You can view the demo here

My eventual intention is that I will develop this plugin into one that can be used for those who offer themes for download, so that it can be used instead of a separate database/install to demonstrate their themes, but I wanted to get this out there now!! Who knows, maybe the official theme browser might adopt a similar technique, it certainly needs something doing to it!

Usage

  1. Unzip epicthemeviewer.zip and upload to your plugin folder.
  2. Go to the plugin management page and activate ‘Epic Theme Viewer’.
  3. Add <?php epic_theme_viewer(); ?> into a page template. See example below.
  4. Create a page where you want to add the theme viewer, and assign your new Page Template to it.
  5. Enjoy!

Example Page Template

The example below uses the default K2 theme.

<?php
/*
Template Name: Theme Viewer
*/
?>
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php epic_theme_viewer(); ?>
</div>
</div>
<?php endwhile; endif; ?>
</div>
<?php get_footer(); ?>

Customisation

If you want to change the amount of columns of themes, open up epicthemeviewer.php and find these lines, changing the number 2 to whatever you want.

$rows = ceil(count($theme_names) / 2);

for ( $col = 1; $col <= 2; $col++ )

if ( $col == 2 ) $class[] = 'right';

By default, only 15 themes are shown per page, but you can change this here:

$per_page = 15;

I’d really love some feedback on this, especially ways to improve the plugin/directions to take the project in.

Issues

Annoyingly, the plugin will only work for logged in users. I’m trying my best to work out why this is, but can’t find any hints as of yet.

Download it here:
Epic Theme Viewer (139)

Submit to Digg! | Add to Del.icio.us! | Add to Technorati Faves! | |

10 Comments
Leave a Comment »

  • i clicked Classic theme’s picture in demo site but always saw Default theme… problem or not?

    Comment by heytbecom — July 15 2008 @ 11:44 pm
  • @heytbecom – Whoops, I just tried again, and you are right. Because I had been logged in whilst testing, I could see all of them, but I logged out, and only the default was there.

    Fixing it now.

    Thanks for the heads up!

    Comment by Alex — July 15 2008 @ 11:52 pm
  • Very cool! Some suggestions:

    1. Provide an admin page to set the options you describe above. Doing that will allow the plugin to be customized per site (I host multiple sites from the same set of WP files) and is less error-prone. Consider using an array for options (see http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays.

    2. When releasing the plugin, include the version number in the file name.

    Comment by David Potter — July 19 2008 @ 12:46 am
  • Thank you for the plugin…I did a little adjustment using another plugin to get it working

    Comment by Jerry Smith — July 22 2008 @ 6:41 am

RSS feed for comments on this post.

Send To Twitter

Back to top

Popular Posts

Latest Commenters