WordPress Plugin: My favorite posts

“My favorite posts”
is a WordPress plugin which allows logged in users to add posts they like to a private favorite post list.

This post will teach you how to use the plugin.

Current Version: 1.2
Last Update: October 10th 2008


First of all you need do download the zip file, unzip it and place the fav_me.php file at your server at /wp-content/plugins/.

Last Update: October 10th 2008, Version: 1.2


Installation is rather easy: just activate the plugin, it will create the database table it needs to work on its own.

Using the Plugin

We leave the no-brainer part to learn something interesting now: how to implement the plugin in your theme.
Basically all you need are 2 functions:

  1. mfp_the_link();
  2. mfp_display();

mfp_the_link will display an “Add this post to your favorite post list” link wherever you call it. Best practice of course is to add the function anywhere INSIDE your WordPress loop. That will create the add link for each post.

You can pass up to two parameters when calling mfp_the_link().
These are: add_link and remove_link.
The syntax is euqal to many wordpress core functions:

mfp_the_link("add_link=add me please&remove_link=remove me please");

This will replace the default link names with the ones you provide. If you want you can add markup as well:

mfp_the_link("add_link=<span class='add_this'>add me please</span>");

mfp_display will display the list of favorite posts anywhere you like. No WordPress loop required here.
So you can put the list in your sidebar, footer, main content area etc.

Of course you can pass parameters here as well. Calling the function without parameters will create an unordered list: each list item will contain a link to the post and a “remove link”.
The default classes added are:

  • ul class: mfp_favorites
  • link class: mfp_link
  • remove link class: mfp_remove_link

So you don’t like my classes? Or you want to display the items in <div> and <p> instead of <ul> and <li>?
Here are the parameters you may change:

  • title : Default is no title
  • display : Default is “list” -> you may change it to “div”
  • remove_link : Text for remove link, Default is “remove”
  • class : Class for ul/div , defaul is “mfp_favorites”
  • link_class : Class for the post link, default is “mfp_link”
  • remove_link_class : Class for remove link, default is “mfp_remove_link”
  • order_by : Order of items, default is ID, you can change that to any field name of the wp_posts table: some examples would be “post_title”, “post_author”, “post_date”. Get the full list at the WordPress Codex.

Some examples:

// Add a h3 title
mfp_display("title=<h3>Favorite Posts</h3>")

// Display as Div with different class names

// Order by post Title & different remove link text
mfp_display("order_by=post_title&remove_link=up up and away");

Another option is to pass the ID of a user to the function. This way it will display another users favorite post list. you can do that by apending the ID as a seperate parameter. The following example would retrieve the posts of user 13 from the database:


One of the best options to use this function would be to show it on the authors page of a user. Just insert the ID of the user dynamically ;)

Another option to display the posts is through the widget added in version 1.2.

Thats it. If you encounter any problems, please tell me via contact form or comments. I would also be glad to hear suggestions for improvements, be it in functionality, usability or code wise.

Have a nice day ;)

Version History:

v.1.0: 03.06.2008
v.1.1: 04.06.2008 (major code change, increased flexibility)
v.1.1.1: 10.06.2008 (minor bug fix: broken <a/> tag & php notice)
v.1.2: 10.08.2008 (added widget support and possibility to display other peoples favorite posts)


This WordPress Theme was discontinued and is no longer available for sale

Tags: ,
165 replies
« Older CommentsNewer Comments »
  1. CSSWorld Webmaster
    CSSWorld Webmaster says:

    hmmm…i have error message:

    Fatal error: Cannot redeclare mfp_install() (previously declared in /customers/xxxxxxx/xxxxxxx/httpd.www/wp-content/themes/design_showcase/functions.php:469) in /customers/xxxxxxx/xxxxxxx/httpd.www/wp-content/plugins/fav_me.php on line 61

    can your help me?

  2. toul
    toul says:

    great. this plugin rocks!
    is there a way to display a custom field and it’s content?
    cheers, thank you.

  3. Joan
    Joan says:

    Great Job!!!

    Not only did your plugin work on WPMU 2.6, but I just decided to switch for wordpress 2.8.5 and it also work like a charm!

    Thanks you very much.

  4. Joan
    Joan says:

    Hi there,
    What a fantastic program you have developed. Can I make it display even if the user is not logged in, so that it keeps the favourites in a cookie which is just temporary ?
    Kind regards,

  5. Talya ???
    Talya ??? says:

    Hi Kriesi,
    Thank you for the plugin.
    I am using the widget displayed as:
    Designer Ice at USD8 a sphere!remove
    Welcome to The Beloved (temp site)remove

    How do I make a space between the post title and “remove”, just like your screen shot above?


  6. Pablo
    Pablo says:

    Hi!, What a pefect plugin!

    I am from Spain, and I’m having problems with some special characters like “&ntilde = ñ”. The plugin takes the “&” like if it was the next parameter but not. How can I scape the “&”? Do you some way to solve problem?


  7. Gaz
    Gaz says:

    Hi Kriesi!

    Great plugin :)

    What are the chances of getting this to store the favorite data within a session or a cookie for unauthenticated users?

    I’ve noticed a couple of requests for this type of feature within these comments already and I think it would be a great addition to this plugin. :)

    Thanks, Gaz

  8. Andrew
    Andrew says:

    I was just sitting down to write this same function, then I found this, Thanks a bunch. Is there any way to just get the IDs out in an array?

    I might write in the cookie function, would you like those functions?

  9. Floyd
    Floyd says:

    Hi Kriesi,
    auch wenn diese Seite englisch ist frage ich mal auf deutsch nach;)
    Gibt es eine Möglichkeit, dass man von der Favoritenseite aus eine E-Mail an den Blogbetreiber schickt, in dem die persönlich beliebtesten Artikel stehen?

    Wäre als Feedback für den Blogbetreiber bestimmt spannend. Ausserdem könntest du so noch einen weiteren Bereich abdecken, den du vielleicht noch gar nicht gesehen hast. Den Bereich des “Merkzettels”. Ich persönlich bin auf der Suche unterschiedliche Artikel in einen Merkzettel zu legen und den Inhalt (Titel der Artikel) an den Blogbetreiber zu schicken.

    Könntest du mir da weiterhelfen? Das wäre hervorragend.

    Besten Dank

Trackbacks & Pingbacks

  1. […] ‘My Favourite Posts’ plugin lets your audience save a list of their favourite posts with one click. They can then login at any […]

  2. […] WordPress Plugin: My favorite posts | Kriesi.at – new media design (tags: wordpress interactive plugin) […]

« Older CommentsNewer Comments »

Comments are closed.