Variable not being passed into WordPress loop

If $my_share echoes as “5171,5167,5165” then it is a string not an array…

In other words array($string) does not equal array(integer,integer,integer) even if $string equals “integer,integer,integer” because array treats $string as a single value with further values separated by commas.

You could use post__in => explode(",", $my_share), to convert the string into an array while passing it… otherwise you could try just using post__in => $my_share, and it might be converted into an array for you (but not sure without delving deep into the code to look.)