[SOLVED] post__in just displays all the records in the post type

I have been struggling the last couple of days with a clients wordpress site where he needs to display a list of speakers (assigned to “speaker” post type) onto another post type layout called “company”.

The goal is to display a list of speakers on the company profile page. The list of speakers by the way is being held in a custom field with the company profile post type in CSV format like this 235,998,2318 etc.

I will not go into the complex nitty gritty of code I attempted to use, all I can say is that nothing related to post__in seemed to work at all. I tried with WP_Query as well as query_posts and got nowhere. I tried what felt like hundreds of forums and articles suggestions. The only results from all attempts to do it the wordpress way  was that the loop would either print out every single speaker or only the first speaker in the array or no speakers at all. It was totally maddening!

Here is my work around using normal php “for” command.

1
[crayon-5d5bbcee5b7dc277738383/]

Hope this helps someone and saves them some time.