Display selected posts on the homepage without featured category
From Alex Denning over at Nometech comes a great hack for magazine style themes with his post "10 Ways to Get That Elusive ‘Magazine’ Look in WordPress".
We are highlighting one hack on that great list, number 7: Display selected posts on the homepage without an extra category.
Most magazine style themes have a featured content part, actually also this theme which was featured before, and these themes want you to create a special category "featured". Then by adding posts to that category visitors will see different posts in the featured content part of the site.
Alex explains that for example when switching themes it is not very useful to have this category "featured" hanging around and therefore the following hack is a great solution in avoiding exactly that.
The trick is to create a custom field called "featured". Then for Posts that you would like to be included in the featured content, you give this custom field a value of 1 (for TRUE).
<?php if (have_posts()) : while (have_posts()) : the_post(); $customField = get_post_custom_values("img"); if ( (isset($customField[0])) && ($customField[0] == "featured") ) { //Custom field have featured as a value, display info the_title(); the_excerpt(); } endwhile; endif; ?>
PS Alex got the original idea from Jean over at WPRecipes
Popularity: 57% [?]





