WP Favorite Posts

Allows users to add favorite posts. This plugin use cookies and database for
saving data.

  • If a user logged in then favorites data will save to database instead of cookies.
  • If user not logged in data will save to cookies.

If you want you can choose “only registered users can favorite a post” option.
There is a widget named “Most Favorited Posts”. And you can use this template
tag for listing most favorited posts;

Most Favorited Posts

If you use WP Super Cache you must add page (which you show favorites) URI to “Accepted Filenames &
Rejected URIs”.

See ChangeLog to learn what’s different between versions.

See more details about
plugin

Download

Latest version: Download WP Favorite Posts v1.5.1 [zip] (Downloaded 7512 times)

Donate

If you like this plugin show your appreciation and make a small donation.

Installation

  1. Unzip into your /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Place <?php if (function_exists('wpfp_link')) { wpfp_link(); } ?> in your
    single.php or page.php template file. Then favorite this post link will appear in all posts.
  4. OR if you DO NOT want the favorite link to appear in every post/page, DO NOT
    use the code above. Just type in [wpfp-link] into the selected post/page
    content and it will embed the print link into that post/page only.
  5. Create a page e.g. “Your Favorites” and insert {{wp-favorite-posts}}
    text into content section. This page will contain users favorite posts.
  6. That’s it :)

229 Responses to WP Favorite Posts

  1. ashley says:

    Hi :)

    I contacted you about the bug where users could rate their unpublished posts via preview, and you released a fix right away, which was awesome! I have another issue now, though…

    I had some test posts up, which I had been favoriting and unfavoring, everything was working perfectly. I trashed those posts today to start putting up real posts in preparation for taking my site live, and when testing the favoriting feature on them (which works fine on the posts themselves) found that there’s no longer anything displaying in my “most favorited posts” widget. Not sure if you added a threshhold for how many times a post has to be favorited or not, but before this, even posts that had been favorited once would show up if the display limit for the widget was large enough.

    I tried removing and replacing the widget as well as deactivating and reactivating the plugin, but no luck. I haven’t done an uninstall/reinstall yet because I didn’t want to lose my settings, but I can try that later tonight if that’s the only fix.

    Really loving this plugin, though, and can’t wait to show you the site I’m using it on! Maybe I can be in your demo list :D

  2. ashley says:

    P.S. statistics ARE enabled ;)

  3. ashley says:

    Just deleted the plugin and reinstalled. All of my settings were still intact, but still nothing in the sidebar widget :(

  4. Emily says:

    This plugin is great, but I’d love to be able to add a thumbnail and I’m totally lost as to how to go about doing that.

    I copied the template into my theme and I tried to use Rosandi’s code from above, but I don’t think I’m putting it in the right place? I can get it to load the default image, but it doesn’t seem to be able to find the thumbnail associated with the post. Guidance would be appreciated. Thanks!

  5. Huseyin Berberoglu says:

    Dave; Thank you. I’ve added your page as demo.

  6. Huseyin Berberoglu says:

    @ashley; I couldn’t reproduce it. Can you give me an explanation step-by-step ?

  7. Huseyin Berberoglu says:

    @Emily; Rosadi’s code pulls first image from post content. If you want to show post thumbnails on favorite posts list page you should use the_post_thumbnail() function.
    For details about function; http://codex.wordpress.org/Template_Tags/the_post_thumbnail

  8. ashley says:

    Sure :)

    I had a few test posts up, and the plugin and widget were working perfectly. Statistics were enabled, and the widget limit was set to 5. I only had 5 test posts and did not favorite them all, but what I had favorited was displaying in the widget.

    I deleted all of my test posts, then put up 2 new posts. Marking/unmarking them as favorites works fine, but now nothing shows up in the widget, even when I have the posts marked as favorites. All I have is the widget title in the sidebar, and it’s blank underneath (until the next sidebar widget displays). Titles of the posts that have been favorited aren’t displaying any more.

    If you email me, I’m happy to give you the site URL so that you can check it out. I just don’t want to make it public yet :)

  9. Ivan says:

    On some servers widget desnt show any links

    fast solution: in wp-favorite-posts.php find line
    function wpfp_list_most_favorited($limit=5)

    and change query to:
    $query = “SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key=’”.WPFP_META_KEY.”‘ AND meta_value > 0 LIMIT 0, $limit”;

  10. Huseyin Berberoglu says:

    @Ivan Thanks. I think the CAST thing causes this problem. But your query doesn’t order the posts.

    I’ll look for a solution of this problem.

  11. Huseyin Berberoglu says:

    @Ivan, i think we should use ROUND; http://www.phpbuilder.com/board/showthread.php?t=10350267

    If ashley mail me the url I’ll test it.

  12. Ivan says:

    @Huseyin Berberoglu, thanks for support!

    Can u explain me: i want widget to show favorite posts of current user. is it possible?

  13. Ivan says:

    @Huseyin Berberoglu,

    I mean for unlogged users, just based on cookies information

  14. Huseyin Berberoglu says:

    It’s not possible with current version of my plugin. Maybe with next versions. If you need it immediately you can contact me for custom work.

  15. Ivan says:

    @Huseyin Berberoglu ,

    Thanks again for reply. I think it’s easy to do, just using your code:

    in same file, function wpfp_widget_init() {

    we need to change wpfp_list_most_favorited($limit); to

    $favorite_post_ids = wpfp_get_users_favorites();
    if (count($favorite_post_ids)) {
    echo “”;
    foreach ($favorite_post_ids as $o):
    $p = get_post($o);
    if ($p->post_status == ‘publish’) {
    echo “”;
    echo “post_title .”‘>” . $p->post_title . ““;
    echo “”;
    }
    endforeach;
    echo “”;
    }

  16. ashley says:

    Just tried the solution that Ivan suggested, and my widget is now displaying “����”.

    Not sure that I did it correctly, I literally just replaced “wpfp_list_most_favorited($limit);” with the code block mentioned.

    About to undo the change, just thought I’d report on my results :)

  17. ashley says:

    Odd, I just hit “undo” on my code editor, save, and reuploaded the file, and it magically works with the original code o.0

  18. Ivan says:

    sorry, i forget to enclose code:


    $favorite_post_ids = wpfp_get_users_favorites();
    if (count($favorite_post_ids)) {
    echo "";
    foreach ($favorite_post_ids as $o):
    $p = get_post($o);
    if ($p->post_status == 'publish') {
    echo "";
    echo "post_title ."'>" . $p->post_title . "";
    echo "";
    }
    endforeach;
    echo "";
    }

  19. ashley says:

    Tried that again, and it gave me the following error:

    “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in /home/*******/public_html/unlabel/wp-content/plugins/wp-favorite-posts/wp-favorite-posts.php on line 368″

  20. ashley says:

    Also, I now have a new issue. I’m back to the original line 350 of wp-favorite-posts.php that magically worked a little while ago:

    wpfp_list_most_favorited($limit);

    I’m testing in IE and Opera at the moment, and now the favoriting isn’t “sticking” in IE. I can favorite a post, hit refresh, and it’s not marked as a favorite any more. It was working fine the last time I played with it in IE, which was last night, and the only thing I’ve changed is that I made and undid the code changes mentioned here. It IS, however, still registering in the count of how many people have favorited the post in the widget. Weird!

  21. Ivan says:

    @ashley,
    sorry, but i cannot put the right code here because i dont know how to put it without removing after submit…
    So i put that code to post in my blog:
    http://deadhorse.spb.ru/how-to-make-wp-favorite-posts-plugin-widget-to-show-posts-of-current-unlogged-user/

  22. ashley says:

    Ah! I was completely misunderstanding the purpose of the code you were posting! Thanks for the link, though ;)

  23. Huseyin Berberoglu says:

    ashley, I found your problem. It was my sql query. The query limits 5 post to show but it includes the trashed ones. so it only shows one published posts. I’ll correct this, and release a new version.

    And with new version I’ll make a new widget named “Show Users Favorites”. Thanks Ivan for show me that so easy to make it :) I didn’t thought it before.

  24. ashley says:

    Yay! Anxiously awaiting the updated release! Thank you so much!!!

  25. Emily says:

    Well I can’t figure out how to add a thumbnail because I can’t use post thumbnails on my site (it’s a multi-author site and they don’t have permission to add a post thumbnail to their posts, that’s why I was trying to pull the first image instead). I tried using the get attachment function, but I really just don’t know PHP well enough to get it to work. Is this a feature you may be able to add in the future? It would be awesome if you did.

    But anyway, I still love this plugin. I just wanted to add another feature request that maybe you could consider for the future. The site I’m using your plugin on is a recipe site so that people can save their favorite recipes and I think finding a specific recipe is going to become an issue for people that save a lot. I would love to add a sorting function (sort by title, sort by category, etc.). I’m using a plugin to sort posts on my index and archive pages, but it doesn’t work on pages. I have no idea if that would be possible or how complicated it might be but I’m just throwing it out there. I think it would be a helpful feature to have.

    Thanks for the great plugin!

  26. Huseyin Berberoglu says:

    @Emily; At the begining I wrote this plugin for http://nefisyemektarifleri.com Turkish best recipe site :) Then I make open-source it.

    Anyway, your requests aren’t generic requests, I mean everyone don’t need these features, only you and maybe a few people. So I couldn’t add this features. There is lot of feature waiting at my todo list which are more useful for everyone.

  27. ashley says:

    You’re going to hate me by the time we’re all done here! I have another issue >.<;;

    If you still have the link to my site, please go and try favoriting/unfavoriting the 2 posts that are currently up. For some reason in my Opera browser, the favoriting isn't "sticking" every time (the "love this band" link is still there, even after I've already favorited the post, but it shows up in my list). I'm having the opposite issue in IE, though. When I "Unlove" posts, they're still showing up in my list.

    Also, iit seems random, but about 8/10 times when I click the "Unlove?" link, instead of loading the "Love this band" link in it's place, it loads a whole page, totally messing up the layout. This is only in Opera, though, not IE.

    I know that probably isn't making much sense, but you'll see what I mean if you go to my site and try it.

  28. ashley says:

    I was wrong. Having the issue of unfavoriting not sticking in Opera as well. I can “Unlove” a post, but it goes right back to being marked as a favorite the next time the page is loaded, and it’s still in my list unless I delete it from the list page itself.

  29. ashley says:

    GAH!!! And now it’s totally working somehow, lol!

    Nevermind :)

  30. Huseyin Berberoglu says:

    @ashley :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>