I have tried "everything" over the years to keep ants out of my hummingbird feeders without success, but have finally solved this problem. As usual as soon as the weather warmed up they arrived in great numbers. I used a wire to hang the feeder, and then twisted an old fashioned fly strip around the wire above the feeder. It has been in place for about 2 months now and not one ant have I seen.
Source: My daughter helped me figure this out.
All websites warn against using anything sticky or greasy. It's possible that when the birds squabble one could accidentally fly into the glue. The best solution is to find the anthill and eliminate it.