The following article was originally written at Cory’s Weblog. For more articles like this either read Cory’s articles here at DevLounge or visit his personal site.
In this article, we are going to create a section in the sidebar of an individual post that will display every time a visitor comes to your blog from a search engine. We are going to optimize this section to let the visitor be aware of the best posts on the blog, posts that are related to the post they came to your blog for, and more.
Getting Started
First, before we start adding features, we need to create a place to put all of this code. To keep everything as simple and easy to code as possible, we are going to create a separate file to hold all the code for this feature. Name it something like searchfriendly.php or something similar.
Now we need to place an include statement in your sidebar. Open sidebar.php and add the following code in right below your search bar:
[php][/php]
So now, your that section of your sidebar should look like this:
[php]
[/php]
Or something similar to that. Notice that I have added the to br tags to make sure that there is even space between the block of code and the search bar. We don’t want things to get too over crowded.
Landing Page
I came across this great plugin from a fellow blogger.
A landing page is the page people arrive on your site from a search engine. When visitors reach your blog from search engines they probably skim your content to see if it is what they are looking for. If not, they are likely to leave your site and perhaps never come back again. So why not help them by showing them related posts to their search on your blog?
You can get more information on this plugin as well as installation instructions at this site.
Popularity Contest
It’s not rocket science to know that you want to tell your new visitors what the best posts are on your blog. This next tip will easily teach you how to do that. This plugin will help you see which of your posts are most popular. Views, comments, etc. are tracked and given point values to determine popularity.
To get this plugin working, you first have to download the package. The, upload the plugin file to your plugin directory in WordPress. Once it is installed, you can change the values of what makes a popular post popular. Once that is all set, now you have to display it in your sidebar. Add the following code right below that last modification we made.
[php]
Most Popular Posts
[/php]
Now, when new visitors come to your site, they will see related posts on the subject that searched for, and also the best and most popular posts overall in all sections of the blog.
Conclusion
So that’s it for this article. I hope you have found these tips useful. The next article I am working on is making the ultimate archives page. This means modifying the default archives page in k2 and adding statistics, most commented posts, a list of the the noteworthy posts (if that plugin is installed) and more. So stay updated for that and as always, your comments and feedback are welcome in the comments. If I have made a mistake, feel free to tell me in the comments.
~Cory
Happy Modding.