I looked at this a little while back and it looked like it could make things easier but I did think the wrapper around it made it look simpler than it would be. I guess you've proved me right.

The thing is, there are some amazing widgets (Justin Tadlock's for example) that let you run just about any query you want so it is hard to think of a situation where you would need to create your own.

The problem with your code is that you started a loop but never closed it again, so PHP was expecting an endforeach and got the end of the function instead.

Andrew’s last blog post..WLTC Plugin Competition: Max Image Size Control