WP-Favorite Posts and BuddyPress
-
Hi!
I’m using WP-Favorite Posts and BuddyPress in my WordPress site, and I’d like to show user’s favorite posts (or at least only the post thumbnail, in a grid view if it’s possible) in their BuddyPress profile.
How can I do this?
Thank you for helping!
https://www.ads-software.com/extend/plugins/wp-favorite-posts/
-
did you ever find a fix for this?
Have you find a fix now? =)
I am using a custom post type called ‘Locations’ where a user can favorite a location. This should get you started in the right direction. Just add your loop in between:
<div class="favoritePlaces"> <h3>My Favorite Places</h3> <?php $favorite_post_ids = wpfp_get_users_favorites($GLOBALS['bp']->displayed_user->userdata->user_login); if($favorite_post_ids) { foreach ($favorite_post_ids as $o) : $p = get_post($o); if ($p->post_status == 'publish') { $postID = get_post_meta( $post->ID); //$locationID = get_post_meta( $post->ID, $postID); //$locations = EM_Locations::get(array('location_id'=>$locationID)); $locationName = $postID[_location_name][0]; $locationCity = $postID[_location_town][0]; $locationState = $postID[_location_state][0]; $locationAddress = $postID[_location_address][0]; //$locationURL = $postID[guid][0]; $locationID = $postID[_location_id][0]; $favCount= $postID[wpfp_favorites][0]; $post_image_url = wp_get_attachment_image_src( $postID ); ?> <div class="feedItem places"> <div class="span5 feedImage placesColumns"> <a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $current_post, 'wpbs-featured-carousel' ); ?></a> </div><!-- end of feedImage --> <div class="span4 feedInfo"> <h3><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a><span class="heart-icon vanilla"><em class="count"><i class="icon-left fa fa-heart"></i><?php echo $favCount ?></em></span></h3> <p class="description"><?php echo $postContent; ?></p> <span class="info"><?php echo $locationAddress; ?><br /><?php echo $locationCity; ?>, <?php echo $locationState; ?></span> <!--<a href="#" target="_blank">clubaron.com</a>--> <ul class="feedLinks"> <li><a class="view-icon" href="<?php the_permalink(); ?>"><i class="icon-left fa fa-search"></i>View</a></li> <?php if (current_user_can('member')) { ?> <li><a href="<?php echo site_url(); ?>?wpfpaction=remove&postid=<?php echo $post->ID ?>" class="heart-icon wpfp-link"><i class="icon-left fa fa-heart"></i>Favorite</a></li> <?php } ?> <li><a class="share-icon popdiv bottom" rel="popdiv" data-content=" <ul class='socialShare'> <!-- facebook --> <li><a class='facebook' href='https://www.facebook.com/sharer.php?u=<?php the_permalink() ?>&t=A New Location from Nightvite' target='_blank' onclick='return fbs_click()'><i class='icon-left fa fa-facebook-square'></i></a></li> <!-- twitter --> <li><a class='twitter' href='https://twitter.com/intent/tweet?original_referer=<?php echo site_url() ?>&text=<?php echo urlencode(get_the_title()) ?>&url=<?php the_permalink() ?>' target='_blank' data-text='Check out this new Nightvite Location' data-count='none' data-hashtags='nightvite' data-url='<?php echo the_permalink(); ?>'><i class='icon-left fa fa-twitter-square'></i></a></li> <!-- google plus --> <li><a class='google' href='#' target='_blank'><i class='icon-left fa fa-google-plus-square'></i></a></li> <!-- email --> <li><a class='email' href='mailto:?subject=<?php gb_e('Nightvite has added a new location:') ?> <?php the_title(); ?>&body=<?php gb_e('Check this new Nightvite Location:') ?> <?php the_title(); ?>%0A<?php the_permalink(); ?>'><i class='icon-left fa fa-envelope'></i></a></li> </ul>"><i class="icon-left fa fa-share"></i>Share</a> </li> </ul> </div><!-- end of feeInfo --> </div><!-- end of feedItem --> <?php } endforeach; ?> <?php } else { ?> <div class="profile-item"> <strong>You currently have no favorite places. Why not <a href="<?php echo get_bloginfo('url'); ?>/places">favorite some places</a> now.</strong> </div> <?php } ?> </div>
You can do this but needs some extra work.
1- add a buddypress sub nav item to member profile page. see bp_core_new_subnav_item()
2- in screen function of new subnav_item you can use wp favorite posts core functions and show displayed user’s favorite posts to public.
code tip;
$fav_array = wpfp_get_users_favorites(bp_get_member_user_id());
and post loop…
Hi,
I would also like to get it so that when someone adds a post as their favorite it shows up on their buddypress profile.
I think I understand most of your steps.
However, can you explain how to post the loop?
After you add…
$fav_array = wpfp_get_users_favorites(bp_get_member_user_id());
how do you post the loop to get it to show the posts?
This is exactly what I need to do but I really don;t understand what you’re saying. Can you tell me step by step, like go here, open this, replace this, etc. etc. I have same exact issue, only my custom post type is properties and I want them to view within BP.
@tim2376 I found a plugin that works with WP Favorite Posts and easily adds the user’s favorites list to their profile menu. BuddyPress Custom Profile Menu
https://www.ads-software.com/support/plugin/buddypress-custom-profile-menu
You have to make sure you use [wp-favorite-posts] instead of {{wp-favorite-posts}}thanks, yes that is how I ended up doing it as well. I just changed that plugin to allow public tab viewing on the profile page and then added a function to show the posts based on the buddypress user’s profile instead of the logged in buddypress user. To do this you can use:
$favorite_post_ids = wpfp_get_users_favorites($GLOBALS['bp']->displayed_user->userdata->user_login);
to get the buddypress users favorites who’s profile you are viewing. Then, you can add the code to display the favorites in the same function. After this, you can use a custom shortcode function to display it on the tab you created.
- The topic ‘WP-Favorite Posts and BuddyPress’ is closed to new replies.