WP Favorite Posts

  • Favorite list is empty.
FavoriteLoadingClear favorites

Your favorite posts saved to your browsers cookies. If you clear cookies also favorite posts will be deleted.

I made a plugin named as WP Favorite Posts. This plugin allows visitors to mark a post as favorite. There is no register requirement because this plugin saves data to cookies. Furthermore it can save data to database if user logged in. The user can see his/her favorite posts list from “Your Favorites” page which you created.

DEMO See it in action

Don’t forget to donate

[paypal-donation purpose=”WP Favorite Posts” reference=”nxsn.com”]

Installation

It’s very easy;

  1. Download the WP Favorite Posts plugin.
  2. Unzip into your /wp-content/plugins/ directory.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Place <?php if (function_exists('wpfp_link')) { wpfp_link(); } ?> in your single.php or index.php template file. Then favorite this post link will appear in all posts.
  5. Create a page e.g. “Your Favorites” and insert text into content section. This page will contain users favorite posts.
  6. That’s it :)

Widget

And there is a widget and template tag for listing most favorited posts. You can go widgets page for using widget. Template tag’s usage;

<h2>Most Favorited Posts</h2>
<?php wpfp_list_most_favorited(10); ?>

The parameter for limiting post count of list. Default value is 5 posts.

Bugs & Appreciations

You can report bugs or write your appreciations by using comments of this post. Also you can see the source code and the ChangeLog. Thanks for using my plugin!

New Feature Request or Need Modification

If you have a feature request or need modification which is urgent for you, contact me. We can make a deal.

Did you like plugin ?

If you like my plugin, i’ll appreciate it if you buy me a coffe or beer! I would love if you write a blog post/tweet etc about my plugin.
[paypal-donation purpose=”WP Favorite Posts” reference=”nxsn.com”]

Some Details

Show Link In Post Content

You can show Add/Remove Favorites Link into post wherever you want with writing FavoriteLoadingAdd to favorites into post content while HTML mode.

Change Template Of “Your Favorites” Page

(version 1.4) You can change “your favorites” page’s templates easily.

First copy wpfp-page-template.php from plugin’s directory to your theme’s directory. Then make template changes (add thumbnail image, make what you want).

If you make something wrong just delete or rename wpfp-page-template.php from your theme’s directory and page’s view will be turn back to basic view.

Who Uses This Plugin ? (DEMO)

http://www.nefisyemektarifleri.com/tarif-defterim/

http://www.hdvideoclip.com/my-playlist

http://www.android-software.fr/mes-favoris

http://www.beckermanphoto.com/your-favorite-prints

396 thoughts on “WP Favorite Posts

  1. Huseyin Berberoglu Post author

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

    Reply
  2. ashley

    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 :)

    Reply
  3. Ivan

    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”;

    Reply
  4. Huseyin Berberoglu Post author

    @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.

    Reply
  5. Ivan

    @Huseyin Berberoglu, thanks for support!

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

    Reply
  6. Huseyin Berberoglu Post author

    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.

    Reply
  7. Ivan

    @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 “”;
    }

    Reply
  8. ashley

    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 :)

    Reply
  9. ashley

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

    Reply
  10. Ivan

    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 "";
    }

    Reply
  11. ashley

    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”

    Reply
  12. ashley

    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!

    Reply
  13. ashley

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

    Reply
  14. Huseyin Berberoglu Post author

    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.

    Reply
  15. Emily

    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!

    Reply
  16. Huseyin Berberoglu Post author

    @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.

    Reply
  17. ashley

    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.

    Reply
  18. ashley

    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.

    Reply
  19. spade

    is there a way to wrap a div tag with some sort of wp-favorite-post short code so that it will hide anythin in the div tag once you mark the post as favorite?

    Reply
  20. spade

    @Huseyin Berberoglu.
    Perhaps I should elaborate a bit better. I understand that its wrapped with the span tag, but what I like to do is use some sort of code such as the code so that when the post is marked as favorite it no longer shows up and is hidden. So is there two separate short codes… one for add to favorites and another to remove from favorites? This way I would be to have something like…

    //this is where i would ad the post loop

    //this would be blank so that nothing would show

    Sorry. I’m not all that good at php so I hope I’m making some sense here.

    Reply
  21. spade

    @Huseyin Berberoglu.
    Perhaps I should elaborate a bit better. I understand that its wrapped with the span tag, but what I like to do is use some sort of code such as the ?php if (function_exists(‘wpfp_link’)) { wpfp_link(); } ? code so that when the post is marked as favorite it no longer shows up and is hidden. So is there two separate short codes… one for add to favorites and another to remove from favorites? This way I would be to have something like…

    ?php if (function_exists(‘wpfp_link’)) { // post is not marked as favorite, then it would show the post ?
    ?php the_content(); ? //this is where i would ad the post loop

    ?php } else { // otherwise, hide post if marked as favorite ?
    //this would be blank so that nothing would show

    ?php } ?

    Sorry. I’m not all that good at php so I hope I’m making some sense here.

    Reply
  22. Ricardo

    Hi,

    I’m using this plugin with this theme:
    http://wpclassipress.com/

    But when I activate this plugin, a error occurs:
    Fatal error: Cannot redeclare wpfp_widget_view() (previously declared in /home/xxx/xxx/wp-content/plugins/wp-favorite-posts/wp-favorite-posts.php:339) in /home/xxx/xxx/wp-content/plugins/wp-favorite-posts/wp-favorite-posts.php on line 339

    Reply

Leave a Reply

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