I want to get all the post ids when the post meta includes a key of "project_id". This function get the job down, but need refine:
function get_all_ids(){
global $wpdb, $post;
$meta_key1 = 'project_id';
$postids = $wpdb->get_col( $wpdb->prepare( "
SELECT key1.post_id
FROM $wpdb->postmeta key1
WHERE key1.meta_key = %s",$meta_key1 ) );
return $postids;
}
This returns arrays of (0 =>1), ( 1 =>3 ), (2 =>5) In the later step, I will need to get the ids like this:
$this->results = $projects->get_all_ids();
This requires the ids are not arrays. How can I get all the ids without array?