Get user favorite posts thumbnail

I’m trying to display a user’s favorited post as thumbnail.
Currently using this code:

<?php
                            $post_id = array( get_user_favorites($user_id, $site_id));
                                $loop = new WP_Query( $post_id ); 
                                if($loop->have_posts()):
                                    while ( $loop->have_posts() ) : $loop->the_post();
                                        if ( has_post_thumbnail() ) : // thumbnail check 
                                        $image   = wp_get_attachment_image_src( get_post_thumbnail_id());                                   

                            ?>
                                <div>
                                <img src="<?php echo esc_url($image[0]); ?>" />
                            </div>
                        <?php

                            endif; 
                            endwhile;
                            endif;
                            wp_reset_query();
                        ?>

This display ALL my blog post as thmbnail but not FAVORITED post.
Any help?

Read more here: Get user favorite posts thumbnail

Leave a Reply

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