• I want users to each have a public page where their favorite posts are listed.
    – With piece of code in functions.php I have managed that each user automatically gets a userpage (i,e. domain.com/member/name). The userpages are generated using a template (i.e. user-profile.php)
    – At this template I am pulling the favorite posts from the database with the code below. This code however pulls the favorite posts of the user who is viewing the page rather then favorite posts of the username of the page. (so that people can share their page).

    Can anyone help me out?

    This is the current code I am using for the userpage.

    <?php $favorite_post_ids = wpfp_get_user_meta() ?>
    		<?php if ($favorite_post_ids):
    			$favorite_post_ids = array_reverse($favorite_post_ids);
    			$post_per_page = 20;
    			$page = intval(get_query_var('paged'));
    			query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page)); ?>
    			<div id="fave_posts_thumbnails">
    				<?php while ( have_posts() ) : the_post(); ?>
    					<div class="entry-image"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>">	<div class="image-info" style="height: 98% ! important;">
                	<div class="title" style="bottom: 0px ! important;"><h2><?php the_title(); ?></h2></div>
    			</div><?php the_post_thumbnail('Entryimage'); ?></a><br><div class="remove-link"><?php wpfp_remove_favorite_link(get_the_ID());?></div></div>
    				<?php endwhile; ?>
    			</div>
    			<div style="clear:both;"></div>
    
    			<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else {
    					$imageloc = get_bloginfo('template_directory');
    					next_posts_link( __( '<div class="nav-previous"><img src="' . $imageloc . '/images/next.png"></div>', 'thisis' ) );
    					previous_posts_link( __( '<div class="nav-next"><img src="' . $imageloc . '/images/previous.png"></div>', 'thisis' ) );
    			}
    			wp_reset_query();
    		else: ?>
    			<div class="entry-text">
    				<?php echo $wpfp_options['favorites_empty']; ?>
    			</div>;
    		<?php endif; ?>
    
    	</div>
        <?php wpfp_cookie_warning();
    	wp_reset_postdata(); ?>

    https://wordpress.org/plugins/wp-favorite-posts/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Database request’ is closed to new replies.