completed refactor of get_posts with @pkarl 's help!