In particular, Erdogan bet big on ISIS to rid himself of both Assad (strategic rival to Turkish influence in the region) and Kurds, so he's not in love with a US policy that arms Kurd troops against ISIS and Al-Nusra.
Also, Turkey is a big country. Daesh is obviously unpopular in "westernized" Istanbul, but out in the sticks where people listen to imams and maybe make the odd cross-border illegal transactions with ISIS fighters, they're likely loved a bit more, especially considering their anti-Kurd role. Coincidentally, rural provinces have also been Erdogan's primary constituencies ever since he failed to attain UE membership.
And well, of course there's Israel.
Edit: downvoted why? I don't think any of this is particularly contentious.
It really is that simple. Turkey has its cosmopolitan side, but numerically they don't match the Erdogan supporters, who in general skew towards the Islamist side.
This is interesting considering the US keeps touting how important allies Turkey is to us for the fight against ISIS. Why is there so much anti-American sentiment right now?
I honestly haven't been able to read that much on the coup so I'm probably missing something - I know you mentioned the US supported Imam, but what else is going on? I seriously would like to know more.