Kari, I’ve provided a working snippet. If it’s not working for you, you might be implementing it incorrectly or the context (location/template/method) you’re implementing it in needs some additional code, e.g. wp_reset_query().
You might want to move your code into a shortcode and then run do_shortcode() in place of where you’re implementing it.
Please try additional implementations to at least get something working and then iterate from there.
Please let me know how this goes for you.