hat I do: in my template that I use to display posts within the standard loop, I make a call to above function:
fs_gallery_featured_thumbs( $post->ID )(originally I usedthe_ID()instead of$post->IDwhich gave me trouble. I guess bescausethe_ID()actually echoes the ID, rihgt?).
Exactly. The problem isn’t in your function itself, but rather in the parameter you pass to it. Because the_ID echoes rather than returns its value, the actual function was getting passed NULL, resulting in attachments for all posts being queried.
Solution:
- Pass
$post->ID(in a context where$postis globalized) - Pass
get_the_ID()(inside the Loop)