I don’t see any reason, given the code above, why it should not be working.
However, the fact that it is outputting the title 24 times leads me to think you have a problem outside of this code.
Is this code inside a have_posts() loop? If yes, how is the query for that loop done? Is it the main WP query or is it a new custom query?