List of faves not printing?
-
Hi I’m trying to display a list of fave posts on a buddypress site, each user has a tab for faves that’s visible to all. I had it working once but now it no longer does – I’ve got to be doing something wrong with this code, but I can’t see what, anyone got any ideas?
$favorites = get_user_favorites(); if ( $favorites ) : // This is important: if an empty array is passed into the WP_Query parameters, all posts will be returned $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; // If you want to include pagination $favorites_query = new WP_Query(array( 'post_type' => 'post', // If you have multiple post types, pass an array 'posts_per_page' => -1, 'ignore_sticky_posts' => true, 'post__in' => $favorites, 'paged' => $paged // If you want to include pagination, and have a specific posts_per_page set )); if ( $favorites_query->have_posts() ) : while ( $favorites_query->have_posts() ) : $favorites_query->the_post(); echo get_the_title(); endwhile; next_posts_link( 'Older Favorites', $favorites_query->max_num_pages ); previous_posts_link( 'Newer Favorites' ); endif; wp_reset_postdata(); else : echo "Please select an item for favorite post list"; endif; }
The fave buttons appear and are clickable so that side of things is working fine. Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘List of faves not printing?’ is closed to new replies.