How to explode single string IF it’s used in shortcode

So from the WP_Query page, I found this, which is like $args[‘name’] but for when you want to search for many slugs:

post_name__in (array) – use post slugs. Specify posts to retrieve. (Will be available in version 4.4)

I think this is maybe what you need?

In that case you’d need to explode $atts['post'] on "," as you did, then pass that resulting array to post_name__in attribute in $attrs. You’re getting that error resulting from trim because you’re passing an array to the ‘name’ attribute in WP Query which is expecting a single slug name in a string.

I’d recommend you explode on "," first, without spaces, then strip off the white space from the resulting strings as that allows for much more freedom in how you (or other users) put stuff in the post attribute in the shortcode.

Let me know if that is or isn’t on the right track or if you want more detailed code example