You’re only seeing one post because with each iteration of the loop you’re overwriting the previous iteration’s value of $ea_var
on the line $ea_var="<article id="post-";
. declare $ea_var
outside the while loop and change that line to append with .=
One other issue you’ve got is the use of $post->ID
won’t work unless you first globalize $post
.
I also suggest you use a new instance of WP_Query
instead of query_posts
, and then just wp_reset_postdata()
after the loop, otherwise the shortcode will have unexpected results in some cases.