Get array of metakey in all posts
Your function is unreliable and totally overboard and really really expensive. Furthermore, as already stated by @MarkKaplun, you are not calling the_post() which causes the $post global not to be updated to the current post being looped through, so the value from get_post_meta() will always have the same value. Although $post_id might work, it is … Read more