Posts module bug when listing favorites
Support › MB Beaver Builder Integration › Posts module bug when listing favorites
- This topic has 3 replies, 2 voices, and was last updated 1 year, 3 months ago by
Peter.
-
AuthorPosts
-
August 5, 2024 at 5:39 AM #46094
Julian
ParticipantHi there
When displaying a user's MB favorites in a Beaver Builder posts module, if they have no favorites, then it defaults to show all posts. But it should show none.
As soon as they have one favorite marked then it only shows one. But if you unfavorite that, then it goes back to showing all posts.
It should show no posts when the users has no favorites.
Can this please be resolved?
Thanks
August 6, 2024 at 10:43 PM #46098Peter
ModeratorHello,
The "user's MB favorites" is a table that shows the list of user's favorite posts, how do you use this with the Beaver posts module? Please share a screen record of those steps so I can reproduce the issue on my demo site.
August 6, 2024 at 11:55 PM #46100Julian
ParticipantI forgot how I did this, sorry. But it was actually by just using the main query in the Beaver Builder posts module, and modifying that query via functions.php using this, which I assume I got from your site:
function tas_not_listened_fl_builder_loop_query_args_filter( $query_args ) { if ( 'tas-metabox-not-listened' == $query_args['settings']->id ) { $user_id = get_current_user_id(); $post_ids = get_user_meta( $user_id, 'mbfp_posts', true ); if ( ! empty( $post_ids ) ) { $query_args['post__not_in'] = $post_ids; // Exclude the post IDs } } return $query_args; } add_filter( 'fl_builder_loop_query_args', 'tas_not_listened_fl_builder_loop_query_args_filter' );August 7, 2024 at 10:51 PM #46107Peter
ModeratorHello,
- As soon as they have one favorite marked then it only shows one
- It should show no posts when the users has no favorites.You can change this logic code
if ( ! empty( $post_ids ) ) { $query_args['post__not_in'] = $post_ids; // Exclude the post IDs }to
if ( ! empty( $post_ids ) ) { $query_args['post__in'] = $post_ids; // Include the post IDs } else { $query_args = []; }however, I see it is the standard behavior of the shortcode
[mbfp-posts]without any difference. Please follow the documentation https://docs.metabox.io/extensions/mb-favorite-posts/#shortcodesAnd please notice that, supporting the custom code is beyond our scope of support. If you have any issues with the code, you can contact an expert developer to help you or contact us here https://metabox.io/contact/. We offer a customization service with an extra fee.
-
AuthorPosts
- You must be logged in to reply to this topic.