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 saved in database instead of cookies.
  • If user not logged in data will saved in cookies.

You can choose “only registered users can favorite a post” option, if you want.
Also 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 more details about
plugin

Download

Latest version: Download WP Favorite Posts v1.5.6 [zip] (Downloaded 21443 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 :)

Changelog

For changelog go here.

376 Comments

  • 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

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

  • 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″

  • 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!

  • @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/

  • ashley

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

  • Huseyin Berberoglu

    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.

  • ashley

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

  • 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!

  • Huseyin Berberoglu

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

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

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

  • ashley

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

    Nevermind :)

  • Huseyin Berberoglu

    @ashley :)

  • rosadi

    How to put do_shortcode in template?
    Thx

  • 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?

  • Huseyin Berberoglu

    @spade, already wrapped with span tag.

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

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

  • 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

  • hello, i user “wp-favorite-post” with plugin “use_parent_category_template_plus”, last plugin have only one file with this code:
    cat_ID) {
    if ( file_exists(TEMPLATEPATH . "/category-" . $category->cat_ID . '.php') ) {
    include(TEMPLATEPATH . "/category-" . $category->cat_ID . '.php');
    exit;
    }
    $category = get_category($category->category_parent);
    }

    elseif (is_single()) :

    $categories = get_the_category($post->ID);

    if (count($categories)) foreach ( $categories as $category ) {
    while ($category->cat_ID) {
    if ( file_exists(TEMPLATEPATH . "/single-" . $category->cat_ID . '.php') ) {
    include(TEMPLATEPATH . "/single-" . $category->cat_ID . '.php');
    exit;
    }
    elseif ( file_exists(TEMPLATEPATH . "/category-" . $category->cat_ID . '.php') ) {
    include(TEMPLATEPATH . "/category-" . $category->cat_ID . '.php');
    exit;
    }
    $category = get_category($category->category_parent);
    }

    }

    endif;

    }
    ?>

    and when “use_parent_category_template_plus” is activated your plugin not corrently worked – on click to link “add to favorite” he do not add the page in favorites, but he open new site window in text area!

    what’s wrong?
    sorry for my english )

  • randy

    “randy; i’m using plugin with php 5.2.12 and there is no problem. Which version of php are you use ? And which version you use of plugin ?”

    Sorry for the tardy reply. I am using PHP 4 and just tried version 1.5. It downloads fine but when activate it I get this below. I am also using a classipress theme which someone else mentioned here. I am hosted with godaddy. Sometimes that is relevant.

    Any ideas? Thanks.

    “Fatal error: Cannot redeclare wpfp_widget_view() (previously declared in /home/content/n/e/w/newengland1/html/wp-content/plugins/wp-favorite-posts/wpfp-widgets.php:3) in /home/content/n/e/w/newengland1/html/wp-content/plugins/wp-favorite-posts/wpfp-widgets.php on line 3″

  • Huseyin Berberoglu

    randy; maybe you wrote function wpfp_widget_view somewhere else ?

    If you use linux server and have ssh account do this while you’re on wp-content;

    grep -lir “function wpfp_widget_view” .

    if it find two file you should remove one of them.

  • randy

    Hi, Thanks for the quick reply.

    I didn’t write anything anywhere else. I downloaded through the WP dashboard/ add new plugin. When you click activate I get the error. I then went through my ftp to delete the plugin and it goes back to normal. I repeated the process but same result.
    Is your advice relevant with this new info?

    “If you use linux server and have ssh account do this while you’re on wp-content;
    grep -lir “function wpfp_widget_view” .
    if it find two file you should remove one of them.”

    I do have a linux account
    Not sure what grep – lir is?

    Thank you.

  • Hi, great plugin. Just having one problem…. For some reason the is being populated with two identical from wp favorites and the result is it showing up as a bar across the top of the page. Can you take a look at the “Your Favorites” page on my site and let me know what you think?

  • J

    anyway to modify this code so it picks up search results?

    EX. (www.site.com/page?search=abc…etc…)

  • Jochen

    Hello Huseyin,

    just tried out your plugin, it really works great. here are a couple of feature requests:
    - BuddyPress compatible: would love to have an option, where a user could favorite a posts over all blogs (wpmu/wp multi) and these get shown on his profile at member/username/favposts for example.

    you plugin is way better than the internal “fav” function where you cannot fav a post on the post itself!

    thanks!

  • Hi Huseyin

    I’m trying to implement some code you offered sometime ago for a different project I was working on, but with the new updates I’m not sure where to place the code. The code looks like this:


    // start custom code for onefiftybyonefifty
    global $post;
    $post = $p;
    get_the_image();
    echo "";
    $post = "";
    // end custom code for onefiftybyonefifty

    I’m trying to allow for images to appear in the “Your Favorites” page, since all the posts are images. You mentioned that I would have to delete this bit of code: echo "id)."' title='". $p->post_title ."'>" . $p->post_title . " ";

    Is that still correct?

    Thanks!

  • Thanks for the plug-in. It’s a really neat tool.

    I don’t know if this is standard behaviour or not, but should the list of user favourites update when the user adds a new favourite? Currently on my installation, the page needs to be refreshed in order for the list to update.

    I have inserted in a div on the sidebar. I’d like to see that list automatically update when the user favourites another post. Can you tell me if this is possible?

    Many thanks.

  • Andy

    Hi,
    thx for the great plugin. Works like a charm. One question though. Is there a possibility to implement the favorite list into some kind of a contact form? I mean, as for example some user adds a few posts as favorites, he might send the list to his email address or maybe to some other user. Therefore it would be great if the fav-list could be send via any contact form implemented into the WP.
    Maybe you have an idea how to manage that. If yes, I would be very thankful to hear from you.
    Wish you all a nice day.
    Cheers
    Andy

Leave a Reply