Support

Account

Home Forums General Issues Querying Posts by User Field Type Reply To: Querying Posts by User Field Type

  • Tweaked the meta_query to add . '"' after $curauth->id to prevent some incorrect matches

    $args = array(
            'post_type' => 'post',
            'meta_query' => array(
    		array(
    			'key' => 'participants',
    			'value' => '"' . $curauth->id . '"',
    			'compare' => 'LIKE'
    		)
    	)
        );
        $wp_query = new WP_Query();
        $wp_query->query( $args );
    
        while ($wp_query->have_posts()) : $wp_query->the_post();
    
     get_template_part( 'partials/loop', 'resources' ); 
    
    endwhile;