How to show your best content forward
Yes… you want to find a room for the best contents of your site… You want to create a hall of fame for those topics you or your audience voted “Best”, and may be you want to create several rooms for several posts groups for several purposes. But you’re tired doing all these things manually, because you forgot to include your last visit to the North Pole. (I’m talking about Bloggers and specially WordPress fans).
I started thinking of that certain topic one week ago when a customer asked me about it. As I browsed around I got one reason to empower my view; Ben Bleikamp got the proof: Blog Architecture: The reason I’m ignoring your blog.
Ben says:
- It’s hard for me to find your best posts. I came to your blog because you wrote something interesting and someone linked to it. Prove to me you have done it before and I’m more likely to come back. Put a related posts plugin on your single post pages so that when someone clicks through they can say “Oh look, this guy wrote about the same topic a few times…maybe I should read those posts too.”
Aha, Related Posts Plugin is nice, but it’s not the end solution. There are different ways to bring that content forward. My favorite technique is calling all those nice posts by tag…
To show your newbie visitors where your best stuff lies, you need to TAG these posts with something like “best-of”. Next, you should find a room in the home page just somewhere in the sidebar or create a standalone page, the decision is just yours. Give that room one short and attractive name, I prefer “Hall of Fame”, but as I said, whether you call it “Hall of Fame” or “Hell of Fame”, the decision is yours again.
I’ve prepared two similar PHP codes depending on where you’re going to hook it up; one for the sidebar and one for standalone page.
Traditionally the sidebar is narrow place and putting excerpts over there is bit awkward, so we’ll only list the TITLES of the best posts. Look at the code below:
The PHP Code for the Sidebar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | < ?php // Query posts query_posts(array( 'tag_slug__and'=>array('best-of'), 'showposts' => 10 ) ); // The loop if(have_posts()) : while(have_posts()) : the_post(); ?> <li><a href="<?php the_permalink(); ?>" title="< ?php the_title(); ?>">< ?php the_title();?></a></li> < ?php endwhile; ?> < ?php endif;?> |
Hmm… The above code would be nice for the sidebar as I stated before, however, many bloggers would like to create a standalone page to hold that data, and as standalone page is a large room, we may include many useful information such as date published, author and excerpts in the code, so it’s enough for a new visitor to understand easily…
The code below is based on a custom page in the default WordPress Kubrick Theme, but you can do it with any theme.
I called this page bestof.php and saved under /wp-content/themes/default/ so the absolute path is /wp-content/themes/default/bestof.php.
The PHP Code for the Standalone Page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | < ?php /* Template Name: Best Of */ ?> < ?php get_header(); ?> <div id="content" class="narrowcolumn"> <h3>The Hall of Fame</h3> <strong>This is a hall of fame for the Best Contents of this blog, in which our readers voted as the best.</strong> < ?php // Query posts query_posts(array( 'tag_slug__and'=>array('best-of'), 'showposts' => 10 ) ); // the loop if(have_posts()) : while(have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to < ?php the_title_attribute(); ?>">< ?php the_title(); ?></a></h2> <small>< ?php the_time('F jS, Y') ?> @ < ?php the_time('H:i:s') ?> by < ?php the_author() ?></small> <div class="entry"> < ?php the_excerpt('Read More...');?> </div> </div> < ?php endwhile; ?> < ?php endif;?> < ?php edit_post_link('Edit this entry.', '<p>', ''); ?> </div> < ?php get_sidebar(); ?> < ?php get_footer(); ?> |
Brief Description:
The PHP code above queries all the posts under the TAG SLUG “best-of”, then it controls the amount of posts required to show; 'showposts'=> 10 only shows the last 10 posts under the slug [best-of], so if your tag is "famous" and you want to show the last 20 posts, then change 'tag_slug__and'=>array('best-of'), to 'tag_slug__and'=>array('famous'), and 'showposts'=> 10 to 'showposts'=> 20.
Demo: Check the “Best of” Tab at the upper corner of my sidebar.
How to
Sidebar
The sidebar part is easy to understand, it needs only to copy or include the contents of best-of-sidebar.php to the sidebar.php.
Standalone Page
Putting the best of contents in standalone page is different and totally unfamiliar to WordPress beginers. You need to download the zipped folder at Download 2, extract the zipped folder and find bestof.php, copy that file (bestof.php) and paste in /wp-content/themes/default/.
Next, go to WordPress admin panel -> Write -> Page. Make a title for your page, leave the “Page” textarea empty and then scroll down and find “Page Template Panel”, then choose “Best Of” from the Dropdown. Look at the image in the left…
Download:
The downloads below contain two parts. Download 1 contains one file, best-of-sidebar.php and Download 2 contains one file; bestof.php.
Download 1 (Sidebar Code): best-of-sidebar.zip
Download 2 (Standalone Page Code): bestof.zip
Popularity: 42% [?]


Thanx J Mehmett for this tutorial, i was really needy for such topic and i’m going to prepare my blog for this code.
thanx again.
James
I changed the style of the second code (the sdandalone page), and now, it’s working right with my theme though I didn’t put on my online site. I tested it on my localhost and i’m gonna use it for online purposes when i feel i need it
Anyways, thank you for the tip.
Hi J Mehmett,
Can you help me compiling this script with I-Theme Powered Blog, I couldn’t do that because I’m not good with CSS.
Please, I’m serious, I need help.