Support Forum
Support › MB Custom Table › ✅meta_query with MB Custom Tables › Reply To: meta_query with MB Custom Tables
Hi,
Thanks for the greeting 🙂
The Custom Table extension hasn't incorporated with the meta query yet. Please use 2 queries to get posts: 1 for getting post IDs from the custom table and one for getting posts. This is the sample code:
global $wpdb;
$post_ids = $wpdb->get_col( $wpdb->prepare(
"SELECT ID FROM your_table
WHERE obh_note_associated_members LIKE %s",
$post->post_author
) );
$query_args = array (
'post_type' => 'obh_note',
'orderby' => 'meta_value',
'meta_key' => 'obh_note_date_time',
'order' => 'ASC',
'post__in' => $post_ids,
);
//The query
$member_notes = new WP_Query( $query_args );