How to add Top Posts page (or list) with My Favorite Posts WordPress plugin (#)
On the very first post of this blog, titled “Importance of Top Posts page for blogs“, I had recommended adding a top posts page and/or list for blogs. Binny, a good friend of mine, commented on that post, asking me of a plugin that I would recommend for the task.
My reply was to use a manual list of posts rather than a plugin. The reason was quite simple: the most popular posts on the blog according to metrics like page views or comments may not reflect the quality of the post. Wacky posts (for example on Apple/Linux) can go viral on social media and upset your top posts list in terms of quality. On the other hand, quality posts with less popularity may be excluded. However, I found a good solution last week: My Favorite Posts WordPress plugin.
Favorite Posts WordPress plugin allows the blog author to manually favorite posts by clicking on a designated link. This means that you can combine the convenience of selecting which posts to display, with the ease of automation. One thing to note is that it requires some effort if you have a blog with hundreds of posts (as in TechZilo).
Using Favorite Posts WordPress plugin
Since the plugin home page lists fewer details about using the plugin than I would like, I decided to write a quick tutorial here. This is a bare-bones tutorial to get things started for everyone, and not meant for advanced use. More parameters that can be passed to the functions, customizations and classes are explained on the plugin home page.
- First, download, unzip, upload and activate the plugin.
- Using the plugin requires two functions: one for the link on which you click to add a post to the list (which will henceforth be called ‘favorite link’), and another function to display the list itself.
- In this example, we will be placing the ‘favorite link’ right after the post in two files:
single.php(to display the link in single pages) andindex.php(to display the link in home page). The position or styling does not matter much, because the link will be visible only to the authors.Open up
single.phpandindex.php, and find a tag like<?php the_content(); ?>. Place the PHP function for the link after the_content tag, so that you get code like so:<?php the_content(); ?>
<?php mfp_the_link(); ?> - Displaying the code in sidebar is slightly tricky, because it will require you to either install a plugin and enter the code in a widget, or edit the
sidebar.phpfile (may be different according to your theme) and place the PHP function. Once you have decided the approach, follow on:Installing the plugin and using widgets:
Install PHP code widget WordPress plugin (requires WP 2.5 or above). Then, go to the Design>Widgets page, drag a PHP widget to your sidebar, enter a suitable title (say “Best Posts”) and enter the following into the widget and save it:<?php mfp_display(); ?>
Editing
sidebar.phpand placing PHP function:
Open your sidebar file (usuallysidebar.php) and place the following code inside the unordered list (<ul>)<li>
<h2>Best Posts</h2>
<?php mfp_display(); ?>
</li>Note that this is not a bullet-proof solution, as it may break in some themes. In that case, you can use our forum for asking support questions :-)
Setting up a separate page for the list, styling the list, using a CSS image replacement for the link etc. are some creative things that can be done, but my guess is that those capable and interested in doing that will not require a tutorial from me, and others probably do not bother with extra work. However, if you are interested, drop me a comment on this post and I will be glad to write a tutorial.
Update: The plugin author has commented below, and explains that the favorite list is visible only to the particular user, and not the public. I had tested the plugin for the code examples above, but did not log out and test. The documentation for the plugin was also found lacking, which led to the confusion. That means that the idea of displaying favorite posts publicly is not possible currently. However, he has said that he considers adding features like option to make the list public, and including widget support. Displaying favorite posts publicly will hence be possible only after the update.
Kriesi said on June 10th, 2008
Hey Sumesh, first of all, thanks for mentioning my plugin and pointing out the php notice and the broken tag.
If I haven’t overlooked anything you meant to fix the php notice for the undefined $fav_post?
Whatever you wanted to do, you deleted some code which is required for the various display options for mfp_display();
I’ve fixed and updated my version in a way which doesn’t kill this option ;) (if you meant to fix another error I would be glad to hear which one, so I can fix it as well)
the other thing i wanted to mention is: I am afraid you got a wrong idea of what this plugin can do: the plugin stores seperate favorite posts for each user: it is kind of a bookmarking system for the users. an Admin can’t add posts to the fav-list and display it to everyone, his favorite posts are only displayed to him. same for every other user.
Altough i might add this option in the near future since it would need only slight modifications of the source code. Adding the post output as a widget is a great idea and another thing i will add as soon as i can spare some time ;)
Have a nice day! Kriesi
Post authorSumesh said on June 10th, 2008
@Kriesi: I knew I’d mess something up ;) I’ve updated the post to delete my update and other minor correction regarding the use of plugin. Thanks for your comment here, and looking forward to those feature updates :)
ajay said on June 28th, 2008
can you please show any example if this plugin