MBFP query not working

Support MB Favorite Posts MBFP query not workingResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45269
    YasmineYasmine
    Participant

    I can't get favourite posts working via the query. Shortcode works. But I need via query. I am using this:

    $current_user = get_current_user_ID();
    $post_ids = get_user_meta( $current_user, 'mbfp_posts', true );
    
    $query = new WP_Query( [
       'post_type' => 'research',
      'post__in' => $post_ids,
       'posts_per_page' => -1,
    ]);
    
    return $query;

    And I followed the instructions here: https://docs.metabox.io/extensions/mb-favorite-posts/

    It shows everything, and I saw that others in the forum had said same issue from using query

    #45272
    PeterPeter
    Moderator

    Hello Yasmine,

    I use the same code on my demo site and don't see the issue. Please add the code to a page template in a standard theme of WordPress without using your custom plugin/theme and recheck this issue.

    $current_user = get_current_user_ID();
    $post_ids = get_user_meta( $current_user, 'mbfp_posts', true );
    
    $the_query = new WP_Query( [
       'post_type' => 'research',
      'post__in' => $post_ids,
       'posts_per_page' => -1,
    ]);
    
    // The Loop.
    if ( $the_query->have_posts() ) {
    	echo '<ul>';
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    		echo '<li>' . esc_html( get_the_title() ) . '</li>';
    	}
    	echo '</ul>';
    }
    
    wp_reset_postdata();
    
    #45277
    YasmineYasmine
    Participant

    Thank you for your reply!

    I just tried to input it via a shortcode and it worked - so something to do with the bricks builder editor. Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.