2 Adding URL to Codex for reference
source | link

Try to use that set of arguments :

$args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'numberposts' => -1,
    'post_parent' => $post->ID,
    'orderby' => 'menu_order',
    'order' => 'asc',
    'post__not_in' => array( $thumb_id )
);

I'm using it for one of my site and it's working fine. So you shouldn't have to use :

 if ($thumb_id==$attachment->ID) continue;

in your loop.

Strangely, the get_posts() Codex Page (http://codex.wordpress.org/Template_Tags/get_posts) says that we could use a exclude parameter, but also says that get_posts() use WP_Query(). And there is no exclude parameter in the Codex for WP_Query()(http://codex.wordpress.org/Class_Reference/WP_Query), only post__not_in.

So, let's use post__not_in instead of exclude.

Looks like a discrepancy.

Try to use that set of arguments :

$args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'numberposts' => -1,
    'post_parent' => $post->ID,
    'orderby' => 'menu_order',
    'order' => 'asc',
    'post__not_in' => array( $thumb_id )
);

I'm using it for one of my site and it's working fine. So you shouldn't have to use :

 if ($thumb_id==$attachment->ID) continue;

in your loop.

Try to use that set of arguments :

$args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'numberposts' => -1,
    'post_parent' => $post->ID,
    'orderby' => 'menu_order',
    'order' => 'asc',
    'post__not_in' => array( $thumb_id )
);

I'm using it for one of my site and it's working fine. So you shouldn't have to use :

 if ($thumb_id==$attachment->ID) continue;

in your loop.

Strangely, the get_posts() Codex Page (http://codex.wordpress.org/Template_Tags/get_posts) says that we could use a exclude parameter, but also says that get_posts() use WP_Query(). And there is no exclude parameter in the Codex for WP_Query()(http://codex.wordpress.org/Class_Reference/WP_Query), only post__not_in.

So, let's use post__not_in instead of exclude.

Looks like a discrepancy.

1
source | link

Try to use that set of arguments :

$args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'numberposts' => -1,
    'post_parent' => $post->ID,
    'orderby' => 'menu_order',
    'order' => 'asc',
    'post__not_in' => array( $thumb_id )
);

I'm using it for one of my site and it's working fine. So you shouldn't have to use :

 if ($thumb_id==$attachment->ID) continue;

in your loop.