Im currently encountering a problem i display user wp favorites posts fine, but the issue is i wont display them, once users are logged out it says " no posts have been made"

while each user has their own posts also once im logged in i can display my favorite posts in my profile but once i visit another profile it displays my favorite posts once again it should display the user's favorite posts instead of mine i have tried bp_displayed_user_id(); but it doesn't seem to do the job, not working at all so i hope someone can solve my problem please...

here's the code itself im using to display the favorite posts on the profiles

<div class="profile-box items-following">

    <h3><?php _e('Items You Follow', 'bd_lang'); ?></h3>

    <div class="profile-content">

        <?php $favorite_post_ids = wpfp_get_users_favorites();
        if($favorite_post_ids) { ?>

                <?php foreach ($favorite_post_ids as $o) : $p = get_post($o); if ($p->post_status == 'publish') { ?>    

                    <div class="profile-item">

                        <!--Begin Image-->
                        <?php if(has_post_thumbnail($o)) { ?>                   
                            <div class="post-thumbnail">
                                <a href="<?php get_permalink($o); ?>" title="<?php echo $p->post_title; ?>">
                                    <?php $image = vt_resize(get_post_thumbnail_id($o), '', 50, 0, true); ?>
                                    <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" alt="<?php if(get_post_meta(get_post_thumbnail_id($o), '_wp_attachment_image_alt', true)) { echo get_post_meta(get_post_thumbnail_id($o), '_wp_attachment_image_alt', true); } else { echo $p->post_title; } ?>" />       
                        <?php } ?>
                        <!--End Image-->

                        <a href="<?php echo get_permalink($o); ?>" title="<?php echo $p->post_title; ?>"><?php echo $p->post_title; ?></a>


                <?php } endforeach; ?>

        <?php } else { ?>

            <div class="profile-item">
                <strong><?php _e('Your are not currently following any items.', 'bd_lang'); ?></strong>

        <?php } ?>


  • alright i get yah but im not trying to assign a specific user/ user id so what can i do about this im trying to make it work for all users instead a user id single so basically each user's profile will have their fav posts box so everyone can go to each other page and view whats their favorite posts, im trying to make myself clear enough. i hope that helps – DeadArtcore Apr 22 '13 at 21:50
  • well i apologize, im no PHP & WP expert im still learning.. yeah your right im trying to get the "ID of the currently viewed page's user" i thought you meant a specific ID thats why i was all lost, well how can i get the "ID of the currently viewed page's user". – DeadArtcore Apr 22 '13 at 22:15
  • no its buddypress in user profiles – DeadArtcore Apr 24 '13 at 17:59

As I understand the plugin (I took just a short glimpse, to be honest) you have to specify a user ID for the wpfp_get_users_favorites() function. Otherwise the currently logged-in user's ID is taken.

Here is everything in a single line:


| improve this answer | |
  • Amazing it works!!!! You are a Light saver ! i cant express myself enough it works now i spend more than 3 days figuring this out and you nailed it thanks so much!! you truly are an expert my friend. also i would like to mention how can i get the favorite posts for a specific category ? if thats not to much to ask. – DeadArtcore Apr 24 '13 at 18:22
  • Glad I could help. Please accept this answer (click the check mark) to indicate your question has been solved. And please ask your other question as a new question to clearly separate the issues. – tfrommen Apr 24 '13 at 18:59
  • I take it, 'bp' refers specifically to BuddyPress. How could I adapt this for WordPress (no BP installed)? Thanks. – pereyra Aug 30 '13 at 6:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.