Archive for category WordPress

Free Dark and Clean WordPress Theme: Designpile

Smashing-magazine-advertisement in Free Dark and Clean WordPress Theme: Designpile
 in Free Dark and Clean WordPress Theme: Designpile  in Free Dark and Clean WordPress Theme: Designpile  in Free Dark and Clean WordPress Theme: Designpile

In this post we are glad to release DesignPile WordPress Theme, a theme designed by Site 5 and released for Smashing Magazine and its readers. The theme comes with 3 color styles and a couple of jQuery-based goodies. It can be used for portfolios and blogs as well as corporate webAs usual, the theme is free to use in private and commerical projects.

Release in Free Dark and Clean WordPress Theme: Designpile

Download the theme for free!

The theme is released under GPL. You can use it for all your projects for free and without any restrictions. Please link to this article if you want to spread the word. You may modify the theme as you wish.

Designpile-main in Free Dark and Clean WordPress Theme: Designpile

Features

Here are some of the features of the theme:

  • Widget ready (footer and sidebar),
  • Easy to setup, the Theme Options Page has 3 color styles,
  • Custom homepage,
  • Simple Post Thumbnails Plugin,
  • 125×125 ads section with enable/disable option, using “WP125″ plugin,
  • JQuery Lightbox,
  • JQuery Forms,
  • AJAX-based based contact form,
  • Live form email validation,
  • Theme Requirements: Wordpress 2.9.1+

Sidebar in Free Dark and Clean WordPress Theme: Designpile
Sidebar

Content in Free Dark and Clean WordPress Theme: Designpile
Content, overview

About in Free Dark and Clean WordPress Theme: Designpile
“About the author”-section

Comments in Free Dark and Clean WordPress Theme: Designpile
Comments

Categories in Free Dark and Clean WordPress Theme: Designpile
Categories archive section

Thank you, Gabi Schiopu and the Site 5 design team! We appreciate your work and your good intentions!


© Smashing Editorial for Smashing Magazine, 2010. | Permalink | 81 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags:

Tags:

WordPress Workshop: Zero to Hero

Leadin Image

I will be hosting a workshop with Refresh Events on advance WordPress theme coding. The event will take place in Toronto, March 25th 2010 at Rich Media Institute, 156 Augusta Ave. This workshop is for designers with CSS skills who want to learn how to convert a HTML template into a WordPress theme (no PHP skills required). You will learn how to advance themes using conditional tags, page templates, custom fields, and more. Details and registration.

Bonus: anyone who signs up for the workshop will get a $45 discount code from InMotion Hosting. You may use the coupon code in any business class shared-hosting, VPS, and dedicated server packages.

Tags:

Unique Blog Posts and WordPress Tips

Leadin Image

Today I would like to talk about blogs that have a unique design for each post. They break the traditional blog layout by designing a different theme for each post based on the topic. Designing a different layout for each topic requires a lot of time and creativity. So, we should appreciate these blogazines who spend their extra time to make your reading more pleasurable. If you would like to join this unique post trend, below are some excellent examples and WordPress tips on how to implement it.

Tags:

SimpleFolio: A Free Clean Portfolio WordPress Theme

Smashing-magazine-advertisement in SimpleFolio: A Free Clean Portfolio WordPress Theme
 in SimpleFolio: A Free Clean Portfolio WordPress Theme  in SimpleFolio: A Free Clean Portfolio WordPress Theme  in SimpleFolio: A Free Clean Portfolio WordPress Theme

Today we are glad to release a beautiful, simple and clean portfolio WordPress theme — SimpleFolio, designed by Omar E. Corrales and released for Smashing Magazine and its readers. SimpleFolio is a portfolio theme that includes a blog and a very extensive option page that allows you to exclude all your portfolio items from the blog page. It also includes a front page slider.

It has 2 different widget areas and threaded comments, and also supports paged comments and has 2 different page templates for advanced usage. The control of images is done from the post page.

Release in SimpleFolio: A Free Clean Portfolio WordPress Theme

Download the theme for free!

The theme is released under GPL. You can use it for all your projects for free and without any restrictions. You may modify the theme as you wish. Please link to this article if you want to spread the word.

Preview in SimpleFolio: A Free Clean Portfolio WordPress Theme

Features

Here are some of the features of the theme:

  • CSS-based layout,
  • 2 columns of fixed width,
  • widget-ready,
  • XHTML 1.0 Transitional valid,
  • multi-browser compatibility: tested on Firefox, Safari , IE7, IE8, Chrome,
  • easy to setup, theme options page.

Scr2 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Front page

Scr4 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Portfolio

Scr5 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Portfolio

Scr3 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Options page in back-end

Scr6 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Single post, main area

Scr7 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Single post, threaded comments

Scr8 in SimpleFolio: A Free Clean Portfolio WordPress Theme
Single post, sidebar

Behind the design

As always, here are some insights from the designer:

I created this theme after getting tired of all the fancy design themes that are very popular now a days, this is a design for people that just need the job done without complicating them selfs. The best use can be either for just someone thats starting to blog or some artist that needs to expose there art.

Thank you, Omar. We appreciate your work and your good intentions!


© Elja Friedman for Smashing Magazine, 2010. | Permalink | 115 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags:

Tags:

Free Christmas and New Year’s Eve WordPress Theme

Smashing-magazine-advertisement in Free Christmas and New Years Eve WordPress Theme
 in Free Christmas and New Years Eve WordPress Theme  in Free Christmas and New Years Eve WordPress Theme  in Free Christmas and New Years Eve WordPress Theme

Spacer in Free Christmas and New Years Eve WordPress Theme

In this post we release our last freebie for the Christmas and the New Year season: a beautiful Christmas and New Year’s Eve WordPress Theme, designed by Site5 and released for Smashing Magazine and its readers. The theme is decorated using Smashing Christmas Icon Set and its main goal is to give a blog a very festive, snowy, New Year’s atmosphere. The theme has no particular requirements, except that the WordPress 2.8.5+ should be installed. As usual, the theme is free to use in private and commerical projects.

Release-image-christmas in Free Christmas and New Years Eve WordPress Theme

Download the theme for free!

The theme is released under GPL. You can use it for all your projects for free and without any restrictions. Please link to this article if you want to spread the word. You may modify the theme as you wish.

Fulltheme-preview in Free Christmas and New Years Eve WordPress Theme

Features

Here are some of the features of the theme:

  • CSS-based layout,
  • 2 columns of fixed width,
  • widget-ready,
  • XHTML 1.0 Transitional valid,
  • multi-browser compatibility: tested on Firefox, Safari , IE7, IE8, Chrome,
  • easy to setup, theme options page,
  • JQuery Lightbox,
  • AJAX-based based contact form,
  • Live form e-mail validation.

Large-sidebar-christmas in Free Christmas and New Years Eve WordPress Theme
Sidebar

Footer-christmas in Free Christmas and New Years Eve WordPress Theme
Footer

Thank you, Gabi. We appreciate your work and your good intentions. And Merry Christmas, folks!


© Smashing Editorial for Smashing Magazine, 2009. | Permalink | 38 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags: , , ,

Tags:

Advanced Power Tips for WordPress Template Developers: Reloaded

width="650">
width="650"> style="width:650px;"> src="http://creatives.commindo-media.de/static/smashing-magazine-advertisement.gif" alt="Smashing-magazine-advertisement in Advanced Power Tips for WordPress Template Developers: Reloaded" border="0" /> /> href="http://creatives.commindo-media.de/www/delivery/ck.php?zoneid=56" > src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=56" border="0" alt=" in Advanced Power Tips for WordPress Template Developers: Reloaded" />  href="http://creatives.commindo-media.de/www/delivery/ck.php?zoneid=63" > src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=63" border="0" alt=" in Advanced Power Tips for WordPress Template Developers: Reloaded" />  href="http://creatives.commindo-media.de/www/delivery/ck.php?zoneid=64" > src="http://creatives.commindo-media.de/www/delivery/avw.php?zoneid=64" border="0" alt=" in Advanced Power Tips for WordPress Template Developers: Reloaded" />

src="http://imp.constantcontact.com/imp/cmp.jsp?impcc=IMP_DIMPBPRSMASHRSS&o=http://img.constantcontact.com/lp/images/standard/spacer.gif" alt="Spacer in Advanced Power Tips for WordPress Template Developers: Reloaded" border="0" width="1" height="1" />

Two weeks ago we published the href="http://www.smashingmagazine.com/2009/11/25/advanced-power-tips-for-wordpress-template-developers/">first part of this article, covering multiple column content techniques and associating pages with post content; we discussed how to use the “More”-tag, hide standalone categories from the category list and retain the page layout for post views within a category page. This article presents the second part of the article; it covers customizing basic content administration and adding features to the post and page editor in WordPress. You would like to see more similar articles in the future? Let us know in the comments to this post!

Customizing Basic Content Administration

Many template developers have learned the art of making beautiful, highly customized front end templates for WordPress. But the real wizards know how to tailor the WordPress administrative console to create a tailored, customized experience for content managers.

Customizing the Dashboard Widgets

The dashboard is the first screen presented to registered visitors when they visit WordPress administration (/wp-admin). Tailoring the dashboard to a client can be the difference between a great first impression and a confused one, particularly if the theme customizes the administrative experience.

The dashboard is comprised of a number of widgets that can be repositioned and toggled using the “screen options” tab. WordPress has a hook – wp_dashboard_setup – that can be used to customize the dashboard widgets, as well as a function – wp_add_dashboard_widget – that allows developers to easily add new widgets.

The WordPress codex href="http://codex.wordpress.org/Dashboard_Widgets_API">documents the process of adding and removing widgets.

Here is a practical use case based on that documentation: let’s remove all of the default widgets that don’t pertain to managing a typical site, and add one simple widget that welcomes the administrator and reminds them how to contact the developer for support.

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

function my_custom_dashboard_widgets() {
   global $wp_meta_boxes;

   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

   wp_add_dashboard_widget('custom_help_widget', 'Help and Support', 'custom_dashboard_help');
}

function custom_dashboard_help() {
   echo '<p>Welcome to your custom theme! Need help? Contact the developer <a href="http://mytemplates.com">here</a>.</p>';
}

class="alignnone size-full wp-image-19154" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-custom-dash.gif" alt="Wp-custom-dash in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="306" />

Customizing the Contextual Help Dropdown

Throughout its administrative panel, WordPress has a small “Help” tab just below the administrative header. Clicking this tab rolls down contextual help for the current administrative page.

class="alignnone size-full wp-image-19155" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-default-context-help.gif" alt="Wp-default-context-help in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="261" />

If your theme has some special functionality that might not be intuitive, it’s a good practice to add some additional contextual help. For example purposes, let’s assume that the theme has been customized to use the “more divider” to separate content into two columns, as described in the first tip. That’s probably not an obvious feature for your average content editor. To accomplish this, hook the contextual help text when on the “new page” and “edit page” administrative pages, and add a note about that feature.

//hook loading of new page and edit page screens
add_action('load-page-new.php','add_custom_help_page');
add_action('load-page.php','add_custom_help_page');

function add_custom_help_page() {
   //the contextual help filter
   add_filter('contextual_help','custom_page_help');
}

function custom_page_help($help) {
   //keep the existing help copy
   echo $help;
   //add some new copy
   echo "<h5>Custom Features</h5>";
   echo "<p>Content placed above the more divider will appear in column 1. Content placed below the divider will appear in column 2.</p>";
}

class="alignnone size-full wp-image-19156" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-custom-context-help.gif" alt="Wp-custom-context-help in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="289" />

Dropping in Your Own Logo

Providing the client some administrative branding can be quick and easy. Here’s how to replace the default WordPress “W” logo in the administrative header with a custom alternative.

First, create an image that fits the allocated space. As of WordPress 2.8, the logo is a 30 pixels wide and 31 pixels tall transparent GIF. When using a transparent GIF or 8-bit PNG, ensure that the image matte matches the header background color: hex value 464646.

A logo named “custom_logo.gif” inside the template directory’s image subfolder can substitute the default WordPress logo with the following code inside the theme’s “functions.php” file.

//hook the administrative header output
add_action('admin_head', 'my_custom_logo');

function my_custom_logo() {
   echo '
      <style type="text/css">
         #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
      </style>
   ';
}

class="alignnone size-full wp-image-19158" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-custom-logo.gif" alt="Wp-custom-logo in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="227" />

Hiding Fields Based on User Role

Basic contributors might be confused or distracted by some of the boxes that surround the page or post editor, particularly if there are a handful of plug-ins that have added their own meta boxes. Alternatively, the content editor might simply want to keep author and contributor hands off of some special fields or features.

Let’s say the content editor wants to keep authors and contributors way from the “custom fields” box. We can use the “remove_meta_box” function – regardless of user role – to remove that from all post editing screens like so:

//hook the admin init
add_action('admin_init','customize_meta_boxes');

function customize_meta_boxes() {
     remove_meta_box('postcustom','post','normal');
}

The “remove_meta_box” function takes three parameters. The first is the ID of the box. The easiest way to discover the ID of the meta box is to look for the ID attribute of the corresponding DIV “postbox” in the source code. The second parameter determines which the context the function applies to: page, post, or link. Finally, the context attribute determines the position within its context: normal, or advanced (in most cases, just setting this to “normal” will work fine).

class="alignnone size-full wp-image-19159" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-find-meta-id.gif" alt="Wp-find-meta-id in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="371" />

The next step is to extend the “customize_meta_boxes” function so that the “custom fields” box – ID “postcustom” – is only hidden from users with author role or lower. We’ll use href="http://codex.wordpress.org/Function_Reference/get_currentuserinfo">get_currentuserinfo to retrieve the user level. According to the WordPress codex, href="http://codex.wordpress.org/Roles_and_Capabilities#Author">authors represent level 2.

//hook the admin init
add_action('admin_init','customize_meta_boxes');

function customize_meta_boxes() {
     //retrieve current user info
     global $current_user;
     get_currentuserinfo();

     //if current user level is less than 3, remove the postcustom meta box
     if ($current_user->user_level < 3)
          remove_meta_box('postcustom','post','normal');
}

Adding Features to the Post & Page Editor

WordPress provides a “custom fields” box that makes it quick and easy to start adding new metadata to your pages and posts. For a tech-savvy client or low budget customization, this is a great, inexpensive method to start href="http://www.smashingmagazine.com/2009/05/13/10-custom-fields-hacks-for-wordpress/">adding some unique fields for a custom implementation.

class="alignnone size-full wp-image-19114" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/sidebar-custom-field.gif" alt="Sidebar-custom-field in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="236" />

But there are plenty of times when something more specialized than a generic “custom fields” box may be appropriate. A less savvy client may be confused by the generic fields that lack any documentation. A checkbox for a Boolean field may be more intuitive for a client than instructions to choose the custom field name from a drop down and type in “1” or “true” under the value. column Or maybe the field should be limited, in select box like fashion, to a few different choices.

The WordPress API can be used to add custom meta boxes to pages and / or posts. And with WordPress 2.8, adding new, tag-like taxonomies is a cinch.

Adding a Custom Meta Box

Let’s say a hyper-local journalist has hired us to build a news blog that covers politics in New York City. The journalist has a few writers on her team, none of whom are particularly tech-savvy, but they will all be set up as authors and posting their reports directly in WordPress. Our imaginary client wants each article associated with a single href="http://en.wikipedia.org/wiki/Borough_%28New_York_City%29">borough, in addition to a “city-wide” option. Articles will never be associated with 2 boroughs, and the staff is prone to typos.

A developer accustomed to basic WordPress administrative customization would probably go to “categories” first. Make a “city-wide” category, with sub-categories for each borough. However, categories are multi-select, and there’s no obvious way to prevent authors from selecting several. Furthermore, the client wants the borough named at the beginning of the article, and if categories are used in other ways (like news topics), extracting the borough name would be a bit tricky.

So how about a “custom field” for “borough”? The authors never remember to look in that generic custom fields box, and in their rush to meet deadlines, occassionally spell the borough wrong, breaking the “filter by borough” feature on the front end.

The right answer is a new custom “meta box,” with a drop down “Borough” field. The WordPress Codex href="http://codex.wordpress.org/Function_Reference/add_meta_box">documents the “add_meta_box” function in detail.

Let’s apply the code discussed in the codex to this use case, assuming we want the “Borough” field to only appear on posts (not pages), and be shown on the top-right of the post editor page.

/* Use the admin_menu action to define the custom boxes */
add_action('admin_menu', 'nyc_boroughs_add_custom_box');

/* Adds a custom section to the "side" of the post edit screen */
function nyc_boroughs_add_custom_box() {
     add_meta_box('nyc_boroughs', 'Applicable Borough', 'nyc_boroughs_custom_box', 'post', 'side', 'high');
}

/* prints the custom field in the new custom post section */
function nyc_boroughs_custom_box() {
     //get post meta value
     global $post;
     $custom = get_post_meta($post->ID,'_nyc_borough',true);

     // use nonce for verification
     echo '<input type="hidden" name="nyc_boroughs_noncename" id="nyc_boroughs_noncename" value="'.wp_create_nonce('nyc-boroughs').'" />';

     // The actual fields for data entry
     echo '<label for="nyc_borough">Borough</label>';
     echo '<select name="nyc_borough" id="nyc_borough" size="1">';

      //lets create an array of boroughs to loop through
      $boroughs = array('Manhattan','Brooklyn','Queens','The Bronx','Staten Island');
      foreach ($boroughs as $borough) {
            echo '<option value="'.$borough.'"';
            if ($custom == $borough) echo ' selected="selected"';
            echo '>'.$borough.'</option>';
      }

     echo "</select>";
}

/* use save_post action to handle data entered */
add_action('save_post', 'nyc_boroughs_save_postdata');

/* when the post is saved, save the custom data */
function nyc_boroughs_save_postdata($post_id) {
     // verify this with nonce because save_post can be triggered at other times
     if (!wp_verify_nonce($_POST['nyc_boroughs_noncename'], 'nyc-boroughs')) return $post_id;

     // do not save if this is an auto save routine
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;

     $nyc_borough = $_POST['nyc_borough'];
     update_post_meta($post_id, '_nyc_borough', $nyc_borough);
}

Take another look at the second to last line in that code block, where the post metadata is updated (update_post_meta will also add the meta if it does not exist). That function stores the field key and value (second and third parameters), assigned to the designated post (first parameter) in the same generic “way” that custom fields are stored. Notice that the field key name was prefaced with an underscore: “_nyc_borough”. Meta fields with keys beginning with an underscore are not shown in the generic “custom fields” box. All other meta fields are shown in that box.

class="alignnone size-full wp-image-19163" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-borough-custom.gif" alt="Wp-borough-custom in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="217" />

We can use this field value in our template just as we would embed generic custom fields.

echo get_post_meta($post->ID, '_nyc_borough', true);

If we want to do a post query that only includes posts in the “Queens” borough, we can execute the query with the following code:

query_posts('meta_key=_nyc_borough&meta_value=Queens');

Adding Custom Taxonomies

A taxonomy, generically defined, is a “classification.” Post tags and categories in WordPress are both types of taxonomies, one of which – categories – has a “hierarchical” proprietary: categories can have child and parent categories. The ability to define new taxonomies has actually been around in some basic form since WordPress 2.3 – but WordPress 2.8 ups the ante, making it incredibly easy for template developers to add and manage tag-like taxonomies.

At the core API level, taxonomies may be hierarchical (or not, a la “tags”) , associated with pages or posts, and have a few other more esoteric properties related to allowing post queries and permalink structures. The potential for custom taxonomies is considerable – posts could easily have two types of categories, pages could have multiple tags, and sites could have multiple tag clouds based on groupings more specific that a generic “tag.”

While the architecture for all of this is all there, the real magic of custom taxonomies – introduced in 2.8 – has only been enabled for posts and non-hierarchical types. But if those qualifications aren’t a show stopper, a developer can get a lot of value out of just a few lines of code: a new tag-like meta box added to posts, a new “posts menu” option for managing those values, and the ability to easily output clouds, filter by taxonomies, design taxonomy templates, and do just about anything one could do with generic “tags” on the front end.

The WordPress Codex outlines the href="http://codex.wordpress.org/Function_Reference/register_taxonomy">“register_taxonomy” function.

Let’s go back to that hyper-local New York City politics blog. Say the editor wants authors to be able to “tag” articles with a distinct “people” taxonomy, but still wants to retain generic tagging. The new “people” taxonomy will highlight the names of political leaders mentioned in articles. On the front end the editor envisions a “tag cloud” that will help the most active politicians get recognized (for better or worse!). Clicking on a leader’s name in the cloud should bring up a list of articles “tagged” with the given politician.

The following few lines of code will add the new “people” meta box to posts and add a new option to the “posts” menu where the taxonomy values can be managed.

//hook into the init action to add the taxonomy
add_action( 'init', 'create_nyc_people_taxonomy');

//create nyc people taxonomy
function create_nyc_people_taxonomy() {
     register_taxonomy('people', 'post', array('hierarchical' => false, 'label' => 'people'));
}

class="alignnone size-full wp-image-19166" src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/11/wp-people-taxonomy.gif" alt="Wp-people-taxonomy in Advanced Power Tips for WordPress Template Developers: Reloaded" width="500" height="281" />

To output a cloud for this custom taxonomy highlighting the 40 most-tagged politicians, the generic “ href="http://codex.wordpress.org/Template_Tags/wp_tag_cloud">wp_tag_cloud” function can be used with a few parameters.

wp_tag_cloud(array('taxonomy' => 'people', 'number' => 40));

To list the highlighted leaders in a single post:

echo get_the_term_list($post->ID, 'people', 'People: ', ', ');

Clicking on a person’s name will automatically take the visitor to an archive for that taxonomy. Custom template files can also be built for the custom taxonomy. A “taxonomy.php” template file in the theme folder can be used for all custom taxonomies. A “taxonomy-people.php” template file could be used for the “people” taxonomy in the example. As with all archives, if no taxonomy-specific template files are available, WordPress will fall back to the generic “archive” and “index” template files.

Further Reading on Custom Meta Boxes and Taxonomies

  • href="http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28">Justin Tadlock on Custom Taxonomies in WordPress 2.8 href="http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28">
  • href="http://www.shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels">Shiba combines meta box and custom taxonomy capabilities in a tutorial
/>

© Jacob Goldman for href="http://www.smashingmagazine.com">Smashing Magazine, 2009. | href="http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/">Permalink | href="http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/#comments">14 comments | title="Bookmark in del.icio.us" href="http://del.icio.us/post?url=http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/&title=Advanced%20Power%20Tips%20for%20WordPress%20Template%20Developers:%20Reloaded">Add to del.icio.us | title="Bookmark in Digg" href="http://digg.com/submit?phase=2&url=http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/">Digg this | title="Stumble on StumbleUpon" href="http://www.stumbleupon.com/submit?url=http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/">Stumble on StumbleUpon! | title="Tweet us!" href="http://twitter.com/home?status=@tweetmeme%20@smashingmag%20Reading%20'Advanced%20Power%20Tips%20for%20WordPress%20Template%20Developers:%20Reloaded'%20http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/">Tweet it! | title="Bookmark in Reddit" href="http://reddit.com/submit?url=http://www.smashingmagazine.com/2009/12/14/advanced-power-tips-for-wordpress-template-developers-reloaded/">Submit to Reddit | href="http://forum.smashingmagazine.com/">Forum Smashing Magazine
Post tags: href="http://www.smashingmagazine.com/tag/wordpress/" rel="tag">wordpress

Update me when site is updated

Tags:

Advanced Power Tips For WordPress Template Developers

Smashing-magazine-advertisement in Advanced Power Tips For WordPress Template Developers
 in Advanced Power Tips For WordPress Template Developers  in Advanced Power Tips For WordPress Template Developers  in Advanced Power Tips For WordPress Template Developers

Spacer in Advanced Power Tips For WordPress Template Developers
Back in July, “Power Tips for WordPress Template Developers” presented 8 basic techniques for adding popular features to the front end of a WordPress-powered website. The premise was that WordPress has become an elegant, lightweight content management solution that offers the fundamentals out of the box, atop a modular core that offers incredible potential in the hands of a capable developer.

WordPress does not try to be an “everything to everyone” CMS right out of the box. Many systems do an average job incorporating 99% of what the potential CMS market might need, even if the last 15-20% is used only by a fraction of the market and adds considerably to the system’s overall “heft” (or bloat). At the other end of the spectrum are completely custom solutions that are finely tailored to exact needs, at the cost of reinventing wheels like polished content editing with media management and version control.

The self-proclaimed WordPress “code poets” have, alternatively, focused on doing an A+ job with the “fat middle”: the 80-85% of features that almost everyone needs, and coupling those with a first rate framework and API that enables capable developers to add in almost any niche or “long tail” feature. In fact, the core WordPress framework is so capable that a handful of “intermediary” frameworks that sit on top of it have already emerged.

That previous “Power Tips” entry scratched the surface, covering a handful of API calls mixed in with some simple PHP code and configuration tips intended to help beginner WordPress template developers kick their game up a notch. This article takes power tips to the next level, expanding on some of the topics in the first article, and introducing more advanced techniques and methods for customizing not only the front end, but the content management (or back end) experience.

You may be interested in the following related posts:

Multiple Column Content Techniques

The average blog or website has a single, clearly defined block of space for a given page’s or post’s unique content. But there are plenty of creative websites that don’t conform to this simple notion of “one unique block” per page. A creative online portfolio layout might feature a screenshot and project description in a left column, and a list of technologies used in a right column. Both the left and right column are unique to each portfolio page.

Here’s a screenshot from an in-development website project, built on WordPress. The “projects” area features portfolio-like layouts of green building projects throughout the state. In addition to a specially designed gallery visualization, note that the individual project profile has two distinct columns.

Rigbc-2-column in Advanced Power Tips For WordPress Template Developers

A more commonplace layout might feature an obvious, primary block of page content, but also feature a sidebar element that is unique to the current page: maybe a quote from a customer about a specific product or service. The “Power Tips” article offered a method to associate sidebar elements with multiple pages using custom fields and page IDs (tip #6). That approach isn’t very effective or efficient for designs with a 1:1 relationship between sidebars and pages (where each page has a unique sidebar element).

Sidebars in Advanced Power Tips For WordPress Template Developers

Yes, the developer could add table buttons to the WordPress editor, and let content authors fend for themselves: a solution prone to problematic layouts and bad output relied upon far too often. Here are a few simple options that keep layout in the hands of the template developer while making content management easier and problem-free.

Short, simple, and HTML free? No worries.

Before we delve into solutions that assume a need for HTML formatting in this second content block, let’s review a more basic solution. If the second column does not need to be formatted – or maybe should not be formatted by the editor for design reasons – then a simple custom field will do the trick. In the case of a simple sidebar element, like a customer quote, this may be just the trick.

There are already great tutorials and useful custom fields hacks that walk through the WordPress custom fields feature, so if you are not familiar with the basic idea behind custom fields, start there. Let’s go ahead and create a custom field named “sidebar_content” (also known as the “key”), and put some simple content in there. Just to shake things up, let’s assume we do need a very basic HTML feature for our content authors, who know nothing about HTML: line and paragraph breaks. Let’s also assume that we want to format this sidebar content on the front end with some of the basic automatic niceties we get when we output post content, like curly quotation marks.

Sidebar-custom-field in Advanced Power Tips For WordPress Template Developers

Here’s how we can output this in any template file, using the “the_content” filter to apply the WordPress content filter to our custom field. That filter converts single line breaks to break tags, double line breaks to paragraphing tags, and even transforms simple quotation marks to curly quotes!

$sidebar_content = get_post_meta($post->ID, "sidebar_content", true);

if ($sidebar_content) {
   echo '<div id="sidebar_content">';
   echo apply_filters("the_content", $sidebar_content);
   echo '</div>';
}

Of course, we can make this even more intuitive for the content authors by creating a new meta field box for sidebar content instead of relying on the generic “custom fields” box… which will be covered later in this article!

Using the More Tag for… More

The WordPress editor has a button “more tag” button that is primarily intended to separate “above the fold” content from “below the fold” content. If you are not already familiar with the “more” divider, read up on that first.

If the pages or posts that need a two column layouts also rely on traditional more separation, this tip will most likely not be effective, unless one of the columns is also the intended “above the fold” content. However, most instances where a two column layout is desirable don’t overlap with a traditional above / below the fold need. It is fairly rare, for instance, for pages (vs. posts) to actually make any use of the more tag. So let’s start taking advantage of that feature!

The basic idea is that content above the more divider will represent one block of HTML content, while content below the divider will represent a second block (be it a sidebar element or column).

Sidebar-using-more-tag in Advanced Power Tips For WordPress Template Developers

Here is how to retrieve content above and below the more divider as separate blocks of HTML content in the corresponding page template file.

global $more;

$more = 0;
echo '<div id="column_one">';
the_content('');
echo '</div>':

$more = 1;
echo '<div id="column_two">';
the_content('',true);
echo '</div>';

The global “more” variable lets WordPress know whether or not the content is being rendered in an “above the fold” (or “teaser”) only view. By passing an empty string to “the_content”, we prevent a “read more” link from showing up below the HTML content. And, for column two, we pass a second parameter to “the_content” – true – which instructs WordPress to output the content without the teaser.

If the intent is to output the second block of content outside of the loop in another template element, such as a sidebar, this approach is a bit trickier. One option would be to store the second block of content in a uniquely named variable, declare it as a global variable in the sidebar, and – if there is any content inside the variable – output a new block. An alternative could involve checking which page template is in use with the “is_page_template” function, and, if the two column template is in use, calling “the_content” with the second parameter set to true, as in the example above.

The Plug-in Solution: Adding a Second HTML Content Block to the Editor

The ideal solution, of course, might be a second HTML editor field on the WordPress page or post editor. Unfortunately, no such plug-in existed… until recently! While writing this article, we decided it was time such a solution did exist, and so the author of this article is happy to present a free, open source plug-in that combines some savvy understanding of how TinyMCE works (hint: it’s as simple as a class name) with the custom meta box tutorial covered later in this article, and a little bit of extra customization and polish thrown into the mix.

Secondary HTML Content adds a second HTML editor to pages, posts, or both (customizable with a simple settings panel). You can output the content in a sidebar with an included widget, or integrate it more tightly with the template by using “the_content_2″ and “get_the_content_2″ functions.

Secondary-html in Advanced Power Tips For WordPress Template Developers

Associating Pages with Post Content: Reloaded

“Power Tips” covered the basic foundation for associating different WordPress pages with different post categories. The basic premise was that many sites require, effectively, different post “feeds” on different pages. For instance, there may be a company blog, but there may also be an independent news feed.

This continuation offers specific tips that extend the core concept introduced in part 1, making it easier to have multiple page / category associations, preventing entrance into the “real” category archive, and ensuring that individual post views retain a visual and architectural association with their parent “category page” layout.

Be sure to read part 1 before proceeding.

A Review of the Basics & the Two Fundamental Approaches

At the heart of the category / page association (covered in part one) was:

  • A matching of the “page slug” with the “category slug.”
  • Using “query_posts” and the category parameter to exclude standalone page categories from the primary feed
  • Using a dedicated page template with “query_posts” and the “category name” parameter to create a page featuring a feed for a single category.

Wp-cat-config in Advanced Power Tips For WordPress Template Developers

Before delving into the tips that extend those ideas, it is important to make a distinction between two common but fundamentally different use cases for page / category association. The more typical use case, which the first part was tailored to, is a website that has a primary feed, like a blog, but also has one or two distinct feeds, most often for a formal news or press feed.

The second use case is a bit more esoteric: there is no primary feed. The site has many pages, and many (but not all) of those top level pages are individual feeds of posts. The example, at the end of this power tip, m62.net, is one such use case. Another common use case might be – again – a portfolio centric website.

Let’s say we want to create “Joe’s Portfolio”, and Joe wants to feature 4 distinct areas of expertise. Each area of expertise should be a top level page, say, joes-portfolio.com/web-design, joes-portfolio.com/graphic-design, etc. Joe wants to have a little write-up about each service area at the top of the page, followed by a feed of case studies. Why a feed instead of sub-pages? Maybe Joe wants prospects to be able to subscribe to an RSS feed for each area of expertise; maybe he wants to easily cross-tag case studies based on industry; maybe he plans to update frequently and doesn’t want a huge page sitemap or wants visitors to page through a date-organized collection of case studies. There are many reasons to use posts instead of pages.

The following tips provide solutions for both use cases.

Automatically Determining the Page / Category Association

Part one suggested that a unique page template be created for any page associated with a category. That page template would then query for posts using a hardcoded category name or category ID. If there are only one or two standalone “category pages”, this is an efficient and effective solution.

However, if there are many page / category associations, as in use case #2 (no primary feed), the process of manually creating page templates for each association is tedious to build and maintain, and not realistic if content editors who don’t program need to be able to create more page / category associations on demand.

An alternative would be to create a generic page template, let’s say “template-category-connector.php”, that is assigned to all pages associated with a category, and automatically determines the right category to query.

The following code performs the matching and executes the post query. The magic happens by taking advantage of our matching page and category slugs. Once again, if the website does not use permalinks, an alternative approach will be required (one permalink-free alternative could involve a custom field with the associated category ID).

$cat = get_category_by_slug($post->post_name);
query_posts('cat='.$cat->term_id);

That’s all there is to it… just proceed on with the post loop to output the applicable category’s posts. Note that the template should probably check for an actual return value from line 1, and output a graceful error in the event there is no match.

Handling Entry into the “Real” Category Archive

Now that there is a dedicated page layout that handles the category feed, we will want to be make certain that the visitor doesn’t land on WordPress’ default category “archive” view. For instance, when using permalinks with the default “category base” value, the archive view for a category with a top level category assigned a “web-design” slug would be: mysiteurl.com/category/web-design. However, the intent is for visitors to view this category at our top level page: mysiteurl.com/web-design.

By combining the WordPress category template file with some smart redirects, we can prevent entry into the default category archive. Out of the box, the WordPress template system allows developers to create global category archive templates as well as templates for individual category archives.

If we are in use case #1 – a site with a traditional blog feed and a standalone news feed on a “press releases” page – we will want to use the latter solution. Let’s say, as in part one, the category ID for “press releases” is 5. We create a template file in our theme folder named category-5.php. Under use case #2 (no primary feed), we will want to redirect all category archive traffic, in which case we need to work with the category.php template file.

A few lines of code in either template file will redirect visitors to the right place. We’ll also pass HTTP error / redirect code “301″ – which will tell search engines to permanently redirect their link to the right location. Note that this particular code assumes we are using a permalink configuration. Line 2 can be modified to accomodate that situation.

$destination = get_bloginfo('url');
$destination .= str_replace('/'.get_option('category_base').'/','/',$_SERVER['REQUEST_URI']);
wp_redirect($destination, 301);

In effect, that code removes the category base (”/category” by default) from the overall relative URL, and safely redirects the visitor to the page with the matching slug. Of course, if the site falls under use case #1 (one or two stand alone feeds), the line three could dropped into a specific category template (i.e. category-5.php) with a hardcoded absolute URL for the redirect destitation.

Hiding Standalone Categories from the Category List & Primary Site Feed

In the first use case (only isolating one or two categories from a primary feed), it may be necessary to prevent isolated categories or the posts within those categories from appearing in some common theme elements that would traditionally include them.

Consider the example from part one: a site with a traditional blog and a standalone press release feed. Assume the owners of the site want the RSS feed for the blog to be persistently available throughout the site (typically manifesting itself as an RSS icon in the browser location bar), but don’t want the press release items included in that primary feed. By default, the WordPress primary feed is available at “/feed”, and includes all published posts, regardless of category or any other post property.

Smashingmag-feed in Advanced Power Tips For WordPress Template Developers

To exclude categories from the primary RSS feed, we need to filter the WordPress function that retrieves the posts. Let’s again assume that the category ID for Press Releases is 5. The following code should be placed in the template’s “functions.php” file.

add_filter('pre_get_posts','exclude_press');

function exclude_press($query) {
   if($query->is_feed && !$query->is_category) $query->set('cat','-5');
}

To summarize, we use the “pre_get_posts” filter to modify the post query before it executes. Within a new filter – named “exclude_press” – a conditional confirms that the post query is for a feed, and that the query is not for an individual category. If the check pans out, the query is modified to exclude category 5 before execution.

The notion of globally filtering the post query may have broader implications depending on the site’s unique requirements. With some smart conditional checking, the filter could be extended to prevent the category from appearing anywhere except within the category or isolated post view. But be careful when extending the filter, and be sure to consider all possible views, including administrative views!

The category list is another frequently used site element that isolated categories should, in most cases, be excluded from. If the template calls the category list in only one or two places by code (as opposed to using the categories widget), excluding categories from the list is straight forward.

wp_list_categories('exclude=5');

However, if the categories widget is in use, or the category list is used throughout the template, an alternative approach is required. Enter the “list_terms_exclusions” filter. Again, the following code should be placed in the “functions.php” template file.

add_filter('list_terms_exclusions', 'filter_press');

function filter_press($exclusions) {
   $exclusions .= " AND t.term_id != 5 ";
   return $exclusions;
}

The return value of a “terms exclusions” filter is tacked onto the “where” clause in the SQL query that retrieves the terms. Without digging too deep here, the reason for discussing “terms” as opposed to, say, “categories” is because WordPress abstracts a variety of different taxonomies (link categories, post categories, tags, custom taxonomies, etc) into a unified database model that handles all taxonomies. Calls to “get categories”, “get tags”, and so forth, are all referring back to general “terms” behind the scenes. Ever wonder why category, tag, and other IDs tend to jump around? They are all being added to the same table. Assuming a fairly clean install, try adding a new post category, and note the ID. Then add a tag, and note its ID… one greater than the new post category.

Term-taxonomies in Advanced Power Tips For WordPress Template Developers

Retaining the Page Layout for Post Views within a Category Page

One of the most common challenges to tackle with page / category association is retaining a sense that the visitor is still within the “category page” hierarchy – and not a global feed hierarchy – when a visitor is reading an individual post. Part one hinted at this challenge under “The devil is in the details,” and started to suggest a path that incorporated using the “in_category” function. We will explain how to use “in_category” within templates, as well as how to trick functions that reference the original query object into thinking that they are “within” the category page.

Let’s start with case #1, and building on the example in the first article, assume we only need to contend with one isolated feed, “Press Releases” (category ID 5).

Say the theme has a sidebar template that lists post categories when rendering the blog part of the site, and when rendering a standalone page, shows a page list instead. Here’s an extremely simplified version of what that might look inside the sidebar template file.

if (is_page())
{
   wp_list_pages();
}
else
{
   wp_list_categories();
}

Of course, there may be alternative widget sets for pages or posts, and there is likely to be more than just one element in the sidebar. But the concept should hold. Now going back to the example, the theme should render posts in category 5 (Press Releases) as if the visitor were on a page (not the blog). Leveraging the “in_category” check, the code above would now like the following:

if (is_page() || in_category(5))
{
   wp_list_pages();
}
else
{
   wp_list_categories();
}

Note that if there are multiple categories whose posts should resemble page output, the “in_category” function should be passed an array of IDs, like so:

in_category(array(5,7));

The need for a “in category” check is probably moot in case #2 (multiple page/category associations, without a primary feed): the template is probably structured to output the same elements on pages and posts from the get go. In other words, everything is handled as if it is a page since there is no primary feed. However, the following tip – that dynamically looks up the faux parent page ID (the page associated with the category) – is necessary for the next part of this tip. Just amend the code to check if “faux_parent_page” has a valid value: if it does, then the post is inside an isolated category associated with a page.

Once again, this approach to dynamically seeking the faux parent page (the category page) depends on taking advantage of the matching permalink structure between post categories and pages that is at the heart of this association. If the site is unable to use permalinks, a more complex alternative look up of the faux parent page will be necessary.

foreach(get_the_category() as $category) {
   $faux_parent_path = '/'.get_category_parents($category, FALSE, '/', TRUE);
}
$faux_parent_page = get_page_by_path($faux_parent_path)->ID;

Now that we have the ID of the category’s associated page, we can trick “black box” theme elements that determine page or post properties on their own (by referencing the post query) into thinking they are actually working with the category page.

The most common use case is page navigation. Whether its breadcrumbs, a top level page menu that should retain “current” (on) states, or a side navigation menu that should display the current section, there are many “black box” navigation functions that need to be tricked into rendering themselves as if on the category page.

Let’s use a simple top level page list, which should maintain proper “current_page”, “current_page_parent” (and so on) classes when on a post under a category page. Here’s what that simple function might look like before our changes:

wp_list_pages('depth=1');

Of course, posts do not normally have parent pages, so there will be no “current” classes assigned to that output when reading a post. Here is how to trick that function into thinking it is rendering the navigation for the “parent” category page.

//retrieve faux parent page dynamically… can skip and hard code in case 1
foreach(get_the_category() as $category) {
   $faux_parent_path = '/'.get_category_parents($category, FALSE, '/', TRUE);
}
$faux_parent_page = get_page_by_path($faux_parent_path)->ID;

//reset the post query as if on the faux parent page
query_posts('page_id='.$faux_parent_page);

//execute our "faked out" function
wp_list_pages('depth=1');

//reset the query back to the initial state
wp_reset_query();

If there are multiple elements that need be “tricked,” a best practice would be to put the “faux parent page” retriever at the top of the template, and declare it a global in any template files that need it. This would avoid repeated look ups of the faux parent page.

An Example: Seeing it All Put Together

A great example of a WordPress-powered CMS that pushes use case #2 to its limits can be seen at the home of m62 visual communications, at http://www.m62.net.

M62-pharm in Advanced Power Tips For WordPress Template Developers

All of the navigation items across the top (Presentation Theory, PowerPoint Slides, etc) are pages associated with post categories. The sub-navigation on the right contains sub-pages that are also associated with sub-categories. For example, in the screenshot above (available here), the visitor is on the “Pharmaceutical Templates” page (faux category), which is a child of the “PowerPoint Templates” page (also a faux category). The content starting with “Download free” (below the page title) is the content from the “Pharmaceutical Templates” page. The posts below the “Next Steps” bar, titled “Latest in Pharmaceutical Templates”, are the posts inside that category. The applicable related category is automatically discovered by the WordPress template, populating the category name “Latest in X” and recent posts. Now let’s look at one of the posts inside that category.

M62-post in Advanced Power Tips For WordPress Template Developers

Using the tips outlined above, the individual post retains the feel of being within the “Pharmaceutical Templates” page, right down to the breadcrumb navigation and “current” states in the navigation.

But not only does m62.net use category / page associations for most top and second level navigation items, it actually extends the concept to tags. The 5 “tabs” on the top right actually represent post tags, and each has a “tag page.”

Stay tuned!

The second part of the post will be published here, on Smashing Magazine, in two weeks. Hence, you may want to subscribe to our RSS-feed and follow us on Twitter. Any ideas or suggestions? Comment on this article!


© Jacob Goldman for Smashing Magazine, 2009. | Permalink | 35 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags: , ,

Tags:

40 Free High-Quality WordPress Themes


  

High quality free Wordpress Themes have become harder and harder to find in the past year, with the influx of premium themes, more and more designers and developers are selling themes (and rightly so, they do amazing work). However, the quality of freely available themes has improved as well; in fact, some themes are very advanced and professional and can serve as a solid foundation for your next designs.

There are a lot of choices out there for someone wanting to choose a Wordpress theme for their blog. But, that aside, the quality is certainly there, and we are sure you will be impressed with this Wordpress theme compilation.

You may be interested in the following related posts:

Free High-Quality WordPress Themes

AppCloud Theme
A nice e-commerce WordPress theme with a clean and professional look. Built upon 960.gs, with an integrated slideshow, two layouts (horizontal and vertical) for app/gadget images. The theme also includes sections “Featured products” and “Top Selling” and a categorized products view.

Berita (via ThemeCloset)
Berita is a minimalist corporate theme created for companies to prominently display their logo, but the theme could be used for any type of website. It’s a feature-rich theme with a preview slider on the front page and a robust theme administration page.

Magazeen
Magazeen is a two-column theme released specifically for Smashing Magazine readers. The theme has some subtle enhancements that encourage looking at related and new posts, like a related posts drop-down effect for the category link.

Mainstream Theme (via Wootheme)
You have the option of choosing from five different theme colors with Mainstream. Thumbnails are automatically resided and the sidebar is widgetized.

Rusty Grunge
Rusty Grunge is a simple WordPress theme yet still gives you the “destroyed” look. This theme utilizes a fully-widgetized sidebar and has been downloaded over 28,000 times and is featured as a pre-installed theme on Dreamhost’s default installation of WordPress.

Obscure WordPress Theme
A dark magazine WordPress theme suitable for any site niche; also a good fit for a community-based site.

Paper Wall
Smashing Magazine released the illustrated theme Paper Wall last month. The inspiration behind the Paper Wall theme was a designer’s desk, as designers typically put things on paper. It’s a two-column theme with many elements of paper: paper boards, peeling paper and paper “menus”.

Gallery WordPress Theme
a beautiful, free, gallery-style Thematic child theme for WordPress, designed by Christopher Wallace especially for Smashing Magazine and its readers. It is extremely flexible and can be used as a starting point for design galleries and portfolios.

Cool Retro
A nice, clean illustrated WordPress theme with a retro-look and nice typography.

Life Collage
Life Collage is a child theme of the Hybrid theme framework. It’s about getting back to the roots of blogging. About sharing our lives. And, about having a little fun while we do it.

Shalom Typo
This theme was designed for the typographic template contest at Smashing Magazine by the German designer David Hellmann. This WordPress theme is based upon this layout. A clean and nice typographic WordPress-theme.

Jungleland Theme (via Theme Lab)
The stylish browns give an earthy feel to this blog making it a good choice for those blogs focused on the environment and nature. It features a photo gallery and a sidebar menu

Monkeypr Theme (via Queness)
Monkeypr is a nicely designed and fun WordPress theme.

Folio Elements Theme (via Press 75)
With its black background, Folio Elements theme will surely make your images and photographs noticed. There is no sidebar, no widgets, no list of categories, no place to comment and nowhere to search. However, if you are looking for a basic carousel-type theme with absolutely no basics, bells or whistles, then Folio Elements might be the one for you.

SimpleCart(js)
SimpleCart(js) is another child of the Thematic Wordpress framework. The theme requires WP E-Commerce and is a flexible way to showcase products with the grid framework. The theme features a rich wood background and simple white content area.

Glassic
A simple clean WordPress theme with the focus on typography and simplicity. Released by Abdullah Ibrahim exclusively for Smashing Magazine and its readers.

Zinepress Theme (via Well Medicatedi)
Zinepress is a two column magazine style theme. There is a nice sidebar with enough space for ads and for your widgets. It is hand coded and has valid XHTML STrict 1.0 and CSS Level 2.1. The developer has successfully tested this them with IE 6.0+, Firefox 2+, Opera 9+, Safari 3+, and Chrome 0.2+. Suggested Wordpress version is 2.7 or higher.

Futurosity Aperio Prototype
Futurosity Aperio is a clean straight-forward blog theme built on Sandbox

Futurosity Vero (via Theme Meme)
Built on Sandbox and Blueprint CSS framework, the Futurosity Vero is a minimalist theme. Near the top of your home page, your most recent and featured post will be displayed.

PolaroidPress (via Tutorial9)
PolaroidPress, as you might guess from the name, plays on the usage of “polaroids” in the theme that display your random images. It’s a simple two-column theme with an airy feel.

H5
The H5 theme is more of a proof-of-concept theme to show designers how to show theme designers how to design with HTML5 and CSS 2.1. It’s a bare-bones theme that’s perfect as a building block for creating your next Wordpress theme.

Inuit (via CSS Reflex)
Inuit makes use of a lot of whitespace and preview images for each post on the homepage. The theme also comes integrated with Twitter and Flickr.

Wu Wei
Clean, modern and minimal. The theme was based on the Taoist concept of wu wei: knowing when to act, and knowing when not to act. The theme is built on the principles of the grid system.

Cardeo Minimal
A minimal three-column theme with plenty of white space and gray text.

Album Theme (by Allan Cole)
Auto-focus is a blog theme designed for photographers to showcase their work.

Mystique (by Digital Nature)
This sleek one column theme has a flexible-width, threaded comments, and an adjustable header.

Manifest
Manifest is a straight-forward one column blog. It has no widgets or sidebar, but gives you a nice clean approach that focuses on your content.

Debug Theme (by Joost de Valk)
When your WordPress installs fail and you need more information, the debug theme is perfect. On the home page, it displays the important URL’s, editor, memory setting, etc. On sub pages it shows the page type, all the query vars that are set and the SQL query for that particular page.

Calmdream WordPress Theme
A very clean and simple layout for magazine layouts.

Portfolio Theme (via WPESP)
Portfolio is a two column blog theme which can be described as a minimalist. This modifiable design will make your own portfolio look great!

Blog Theme
The Carrington Blog-style theme is filled with advanced features like widgetized sidebars, AJAX loading of content, stylish galleries, customizable headers and colors.

Mobile Theme (via Carrington Themesl)
The Carrington Mobile has a beautiful design supporting advanced touch browsers (Android, BlackBerry, iPhone and Pre).

Pyrmont V2 Theme (via WP)
Pyrmont V2 is a two-column theme with a black background that could very well make your photographs and designs stand out.

Destyle Theme
Destyle is a magazine-style WordPress theme. This is another theme packed with useful features such as: multi-level superfish dropdown menu, ad management, predefined CSS styles, customa page templates, Twitter and Flick badges on sidebar and automatic image resizing.

ImpreZZ
A dark, three-column theme that gives the second column a third dimension.

Would you like to see more similar lists on SM?

Your opinion is very important to us. There are literally hundreds of similar lists on various design blogs. We are trying to do our best to present you only the best of the best, collecting useful links over months. Would you like to see more similar lists in the future? Or should we drop lists altogether and focus on more original content?


© Smashing Editorial for Smashing Magazine, 2009. | Permalink | 63 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags: ,

Tags:

Glassical: A Free WordPress Theme


  

We love our readers. We respect the hard work of designers and developers across the globe. And we do our best to make the web design community stronger and the Web a little bit prettier. Therefore we ask talented artists and creative professionals to showcase their skills and release something unique and beautiful as a gift to the community. And when designers agree, impressive works see the light of day.

Screenshot

Today we are glad to release Glassical — a free professional Wordpress-theme created by Abdullah Ibrahim. This theme was designed with the main focus being on typography, clean look and simplicity. Hopefully, you will be able to use it in your projects or at least use it as a foundation for your next projects. The theme is released especially for Smashing Magazine and its readers.

Download the theme for free!

The theme is released under GPL. You can use it for all your projects for free and without any restrictions. Please link to this article if you would like to spread the word. You may modify the theme as you wish. The theme supports the WordPress 2.8 nested comment system and it is also customized for the WP Pagenavi plugin. Also, Cufón is used for embedding the Nevis font into the theme.

Screenshot

Screenshots

Below you’ll find more screenshots of the theme. You can click on an image to see the enlarge version.

“Filed under” and “Comments”-section

Wordpress Theme

“Categories”-section

Wordpress Theme

Design of a <blockquote>

Wordpress Theme

Last but not least…

Thank you, Abdullah! We appreciate your work and your good intentions.

We are regularly looking for creative designers and artists. You may not know it yet, but we might feature you in one of our upcoming posts.

If you want to release a high-quality free font, a Wordpress-theme, some wallpapers or an icon-set, please contact us — we would like to support you.

You may be interested in the following free Wordpress-themes as well:


© Smashing Editorial for Smashing Magazine, 2009. | Permalink | 59 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags: ,

Tags:

10 Useful WordPress Coding Techniques


  

10 Useful WordPress Coding Techniques (via @smashingmag) -

Since last year, the WordPress themes market has grown incredibly. The reason? Great designs, of course, but also a lot of amazing new functionality. Top WordPress developers are always looking to get the most out of WordPress and use all of their knowledge to find ways to make their favorite blogging engine even more powerful.

In this article, we have compiled 10 useful WordPress code snippets, hacks and tips to help you create a WordPress theme that stands out from the crowd.

You may be interested in the following related posts:

1. Style Posts Individually

Screenshot

The problem.
Your blog has a lot of posts, but the posts aren’t all of the same type. To give special styling to one or more of your posts, you can take advantage of both the post_class() function and the post ID.

The solution.
To apply this trick, just open your single.php file, find the loop and replace it with the following:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<?php the_content(); ?>
</div>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>

Code explanation.
The important part is mostly in line 3. Here, we have added the PHP post_class() function. Introduced in WordPress 2.8, this function adds CSS classes to the post. For example, it can add:

  • .hentry
  • .sticky
  • .category-tutorials
  • .tag-wordpress

With these CSS classes now added, you can now give a custom style to all posts that have the sticky tag or those that belong to the tutorials category.

The other important piece of this code is id="post-<?php the_ID(); ?>". By displaying the ID of the post here, we’re able to style a particular post. As an example:

#post-876{
	background:#ccc;
}

Source:

2. Display Related Posts… With Thumbnails!

Screenshot

The problem.
After they have read your latest post, what do your readers do? That’s easy: most of them simply leave. A great way to keep them interested is to display a list of related posts. Many plug-ins can do that, but for those who like to know how things works, here is some nice code to get related posts and their thumbnails.

The solution.
Simply paste this code after the the_content() function in your single.php file:

<?php
$original_post = $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
  echo '<h2>Related Posts</h2>';
  $first_tag = $tags[0]->term_id;
  $args=array(
    'tag__in' => array($first_tag),
    'post__not_in' => array($post->ID),
    'showposts'=>4,
    'caller_get_posts'=>1
   );
  $my_query = new WP_Query($args);
  if( $my_query->have_posts() ) {
    echo "<ul>";
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <li><img src="<?php bloginfo('template_directory'); ?>/timthumb/timthumb.php?src=<?php echo get_post_meta($post->ID, "post-img", true); ?>&h=40&w=40&zc=1" alt="" /><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile;
    echo "</ul>";
  }
}
$post = $original_post;
wp_reset_query();
?>

Code explanation.
First, this code makes use of TimbThumb, a PHP image-resizing script. We have used it to automatically resize images to 40 by 40 pixels.

Once this code is pasted in your theme, it uses the first tag of the post to fetch related posts. In this example, four related posts are displayed. You can change this number on line 10.

Also, notice that I have cloned the $post variable at the beginning of the script and restored it at the end. This prevents problems that may occur with the loop, such as comments being assigned to the wrong post.

Source:

3. Alternate Post Styling On Your Home Page

Screenshot

The problem.
Many new WordPress themes have an amazing way of displaying posts on the home page. For example, we can display the first three posts bigger than the rest, with images and extended text, with the remaining posts shown more simply.

I have seen many themes in which developers use two distinct loops to achieve this, which isn’t necessary and can cause further problems. Let’s use a much simpler method.

The solution.
Here is a custom loop that displays the first three posts different than the rest. You can replace the existing loop in your index.php file with this code.

<?php
$postnum = 0;
while (have_posts()) : the_post(); ?>

<?php if ($postnum <= 3){ ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  <div class="date"><span><?php the_time('M j') ?></span></div>
    <h2>(<?php echo $postnum;?>)<a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
	<div class="post-image" style="text-align:center;">
		<a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_directory' ); ?>/timthumb.php?src=<?php  echo catch_that_image(); ?>&amp;w=500&amp;h=200&amp;zc=1" alt="<?php the_title(); ?>" /></a>
	</div>
	<p><?php the_content('Read the rest of this entry &raquo;'); ?></p>
	<p class="more"><a href="#">Read More</a></p>
  </div>
</div>

<?php } else {
<div <?php post_class( 'single ' . $end ); ?> id="post-<?php the_ID(); ?>">
	<div class="post-content">
		<h3><a href="<?php the_permalink() ?>">(<?php echo $postnum; ?>)<?php the_title(); ?></a> <?php edit_post_link('_', '', ''); ?></h3>
		<p><?php the_excerpt( '' ); ?></p>
		<p class="more"><a href="#">Read More ?</a></p>
	</div>
</div><!-- End post -->

<?php }
	endwhile;
	?>

Code explanation.
Nothing hard here! We just created a PHP variable, named $postnum, which is invoked at the end of the loop. If $postnum is less than or equal to 3, the post is displayed in full. Otherwise, it is displayed in its more compact form.

4. Using Multiple Loops

Screenshot

The problem.
When coding complex WordPress pages with more than one loop, it can happen that one of the loops doesn’t behave as expected: for example, unwanted offset, repeated posts, etc. Happily, with a bit of knowledge and a very useful function, we can avoid this.

The solution.
The following example features two distinct loops. Notice the rewind_posts() function on line 8. This example can be used on any WordPress file as is: index.php, single.php, etc.

// First loop (get the last 3 posts in the "featured" category)
<?php query_posts('category_name=featured&showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
  <!-- Do stuff... -->
<?php endwhile;?>

//loop reset
<?php rewind_posts(); ?>

//Second loop (Get all posts)
<?php while (have_posts()) : the_post(); ?>
  <!-- Do stuff... -->
<?php endwhile; ?>

Code explanation.
This piece of code doesn’t use any hacks; rewind_posts() is a standard WordPress function.

The purpose of rewind_posts() is to “clear” a loop that has been previously used (like the first loop in our example above), allowing you to use a second loop that isn’t affected by the first loop’s results.

Source:

5. Overwrite Post Titles Easily

Screenshot

The problem.
the_title() is a basic but very useful WordPress function: it displays the post or page’s title. No more, no less. But hey, have you ever wished you were able to display the full title in your listing of posts and a custom title on the actual post’s page? If so, find out how right here.

The solution.
In your single.php file, find the call to the the_title() function and replace it with the following code:

<?php $title = get_post_meta($post->ID, "custom-title", true);
if ($title != "") {
	echo "<h1>".$title."</h1>";
} else { ?>
	<h1><?php the_title(); ?></h1>
<?php } ?>

Once that’s done, you can rewrite the post’s title by creating a field named custom-title. Its value will be your custom title for this post.

Code explanation.
When this code loads, it retrieves the meta field named custom-title. If this meta field exists and isn’t blank, it is displayed as the post’s title. Otherwise, the the_title() function is called, and the post’s regular title is displayed.

Source:

6. Add Multiple Sidebars

Screenshot

The problem.
Sidebars are great because they allow you to display a lot of useful info, such as related posts, author info, a blog roll, 125×125-pixel ad spaces and so on. But sidebars can quickly become very busy, and readers may be hard-pressed to find what they’re looking for. So, what about having different sidebars available and displaying the most appropriate one for the post?

The solution.
To apply this hack, duplicate your sidebar.php file and fill it with whatever information you would like to appear. Save the file as sidebar-whatever.php.

Once that’s done, open your single.php* file and find the call to the get_sidebar() function:

<?php get_sidebar(); ?>

Replace it with:

<?php $sidebar = get_post_meta($post->ID, "sidebar", true);
get_sidebar($sidebar);
?>

Now when you write a post, create a custom field named sidebar. Set its value as the name of the sidebar that you want to include. For example, if its value is right, WordPress will automatically include sidebar-right.php as a sidebar.

If no custom sidebar field is found, WordPress automatically includes the default sidebar.

*The same can be done with page.php.

Code explanation.
This trick is quite simple. The first thing we did was look for a custom field named sidebar and get its value as a variable. Then, the variable is used as a parameter for the WordPress function get_sidebar(), which allows us to specify a particular file to use as a sidebar.

Source:

7. Display Content Only To Registered Users

Screenshot

The problem.
As you probably know, WordPress lets you decide whether to allow readers to create accounts and sign in to your blog. If you want to increase your blog’s registered readers or would just like to reward existing readers, why not keep some content private, just for them?

The solution.
To achieve this hack, we’ll use a shortcode. The first step is to create it. Open your functions.php file and paste the following code:

function member_check_shortcode($atts, $content = null) {
  if (is_user_logged_in() && !is_null($content) && !is_feed()) {
    return $content;
  } else {
    return 'Sorry, this part is only available to our members. Click here to become a member!';
}

add_shortcode('member', 'member_check_shortcode');

Once that’s done, you can add the following to your posts to create a section or text (or any other content) that will be displayed only to registered users:

[member]
This text will be displayed only to registered users.
[/member]

That’s it. Registered users will see the text contained in the shortcode, while unregistered users will see a message asking them to register.

Code explanation.
The first thing we’ve done is create a function named member_check_shortcode, which checks whether the current user is logged in. If they are, then the text contained in the [member] shortcode is displayed. Otherwise, the message on line 5 is shown.

If you’d like to know more about WordPress shortcodes, you should definitely have a look at our Mastering WordPress Shortcodes post.

Source:

8. Display Your Most Popular Content In The Sidebar

Screenshot

The problem.
If you want to feature your best content and help readers discover more articles from your blog, you might want to display a list of your most popular posts, based on the number of comments they’ve received, in your sidebar.

The solution.
This code is really easy to implement. Just paste it wherever you’d like your popular posts to appear. To get more or less than five posts, just change the value of the SQL limit clause on line 3.

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">

<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>

Code explanation.
In this code, we use the $wpdb object to send a custom SQL query to the WordPress database. Then we verify that the results aren’t empty (i.e. that no posts are without comments), and finally we display the list of posts.

Sources

9. Create A Drop-Down Menu For Easy Tag Navigation

Screenshot

The problem.
Tags are cool because they allow you to categorize content using precise terms. But displaying tag clouds is a problem: they are ugly, not easy to use and can be extremely big.

So, what’s the solution? Simply create a drop-down menu for your tags. That way, they don’t get in the way, but people still have easy access to them.

The solution.
To create our drop-down menu of tags, we first have to paste the two functions below into the functions.php file of our WordPress theme:

<?php
function dropdown_tag_cloud( $args = '' ) {
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags

	if ( empty($tags) )
		return;

	$return = dropdown_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag_cloud', $return, $args );
}

function dropdown_generate_tag_cloud( $tags, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$tags )
		return;
	$counts = $tag_links = array();
	foreach ( (array) $tags as $tag ) {
		$counts[$tag->name] = $tag->count;
		$tag_links[$tag->name] = get_tag_link( $tag->term_id );
		if ( is_wp_error( $tag_links[$tag->name] ) )
			return $tag_links[$tag->name];
		$tag_ids[$tag->name] = $tag->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';

	foreach ( $counts as $tag => $count ) {
		$tag_id = $tag_ids[$tag];
		$tag_link = clean_url($tag_links[$tag]);
		$tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag ));
		$a[] = "\t<option value='$tag_link'>$tag ($count)</option>";
	}

		switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'dropdown_generate_tag_cloud', $return, $tags, $args );
}
?>

Once you’ve pasted this function in your functions.php file, you can use it to create your drop-down menu of tags. Just open the file where you want the list to be displayed and paste the following code:

<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
	<option value="#">Liste d'auteurs</option>
	<?php dropdown_tag_cloud('number=0&order=asc'); ?>

</select>

Code explanation.
To achieve this hack, we take the wp_tag_cloud() WordPress function and rewrite it to make it display tags in an HTML “Select” element.

Then, we just call the newly created dropdown_tag_cloud() in our theme to display the drop-down menu items.

Source:

10. Auto-Resize Images Using TimThumb And WordPress Shortcodes

Screenshot

The problem.
A good blog post needs images, whether screenshots or simple eye-candy. Readers always prefer articles with nice pictures to plain boring text.

But images can be a pain to deal with, especially because of their various sizes. So how about we create a WordPress shortcode that uses Timthumb to automatically resize images?

The solution.
The first thing to do is create the shortcode. Paste the following code in your functions.php file:

function imageresizer( $atts, $content = null ) {
	return '<img src="http://media2.smashingmagazine.com/wp-content/uploads/2009/10//timthumb/timthumb.php?src='.$content.'&w=590" alt="" />';
}

add_shortcode('img', 'imageresizer');

Now, you can use the following syntax to add an automatically resized image to your blog post:

[img]http://www.yoursite.com/yourimage.jpg[/img]

Code explanation.
You have probably already noticed how cool WordPress shortcodes are and how they make your blogging life easier. This code simply creates a shortcode that takes a single parameter: the image’s URL. Please notice that it’s not a good idea to resize large images this way as it unnecessarily increases the server load – in such cases it’s better to create and upload smaller images instead.

TimThumb resizes the image to 590 pixels wide, as specified on line 2 (w=590). Of course, you can change this value or add a height parameter (e.g. h=60).

Source:

Related posts

You may be interested in the following related posts:

About the Author

This guest post was written by Jean-Baptiste Jung, a 27-year-old WordPress expert from the French-speaking part of Belgium. He blogs about WordPress at WpRecipes, about practical Web development tips at Cats Who Code and about blogging at Cats Who Blog. You can stay in touch with Jean by following him on Twitter.

(al)


© Jean-Baptiste Jung for Smashing Magazine, 2009. | Permalink | 71 comments | Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine
Post tags: , ,

Tags: