I'm working on a wpdb query and it's just not running. And for some reason the error reporting for wpdb isn't giving me any errors.
So, can anyone spot an obvious mistake in this query?
I'm attempting to get the meta_value
of all _sell_media_attached_file
keys in the post_meta
table.
I'm first running a wp_query
, getting the post ID's and then running each post ID through the wpdb query.
Here's what I'm working with:
// run the loop
$loop = new WP_Query( array(
'post_type' => 'sell_media_item',
'collection' => $club,
'include_children' => false,
'year' => $year,
'monthnum' => $month,
'day' => $day,
'fields' => 'ids',
) );
if ( $post_ids = $loop->get_posts() ) {
$post_ids = implode( ',', $post_ids );
//breaks here
$atts_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $post_ids AND meta_key = '_sell_media_attached_file' " );
echo('<b>query:</b> <pre>'); var_dump($atts_ids);
But as I say, nothing get's output in the var_dump
and if I add $wpdb->print_error();
I get no errors.