wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); Getting thumb from wrong loop

I am using a plugin which sets the thumbail for your fb share image. The src is

<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

Which was working fine, but not it’s showing thumb X on every page (rather then the currect thumbnail) I found the problem is I have a loop in the sidebar.

Is there a way to make

<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

Get its attachment from the FIRST loop (as this code is at the bottom of the page)

Or is there some other hack to make it get it from the first loop?

Solutions Collecting From Web of "wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); Getting thumb from wrong loop"