Here’s the problem:
$my_query = new WP_Query('cat=7');
You asked for posts in the category with the ID 7. You never said anything about how many posts to fetch, so it fetches the default, 10 per page.
So instead, you need to set posts_per_page, and you need to set it to a reasonable number such as 50. Bever set it to -1, even if you want to show them all, set it to a high number but never -1.
Some additional notes:
- Don’t use string parsing!
WP_Query( [ 'cat' => 7 ] )is a bit nicer, a tiny bit faster, and it allows you to use nested parameters such astax_query. Avoid tutorials that use the string syntax - The
wp_reset_postdatashould come after thewhileloop, but it should be inside theifblock. Otherwise there is no postdata to reset! - If
get_post_metafails on any of those IDs it will cause problems. Assign them to variables then check the result and give them default values if they’ve failed - Don’t hardcode magic numbers like
7, to be honest you should probably have made a custom post type instead of repurposing a category