Try putting a wp_reset_query function call after your loop on the homepage template.
If you’re using a custom query on the home page and not used wp_reset_query
, then the conditional check will always point to the last post fetched by that custom query hence failing to check if homepage.