I am just trying to understand how coding in Wordpress works. I have read a bunch of tutorials about post loops and how to modify them with queries, but I have no idea how individual page content I create with Wordpress using a template from a theme is integrated with that, so that my page is displayed in the end, with any posts I want to see there formatted the way I specified it.
Like e.g. I am building a page using Wordpress' twentytwentyone theme's "index.php" template. It just contains a simple post loop. How is the stuff I created (with specific elements) and layout incorporated into that? How does the code in the theme get put together with my page design and elements I put on that page?
To put it differenty: I add a new page in Wordpress, tell Wordpress which template to use, and create some Wordpress blocks and elements in that page. How does that all get merged together? Does Wordpress "magically" put my page code in the post loop body from the template?
What happens if I create and use a template with multiple post loops? Like let's say I have two different post categories, and I want to display the posts from the first category somewhere up my page, and posts from the second category further down?
Also, how would I go about showing e.g. 10 posts of a category, and when the user clicks some "next" button, show the next 10, and so on?
And let's say I put some php code in my page to format the posts, how does that code get fed with the posts from the post loop? twentytwentyone's index.php's post loop already calls the_post() and get_template_part(...). According to the Wordpress codex, the_post() simply "interates the post index in the loop". Does that mean that the data of the post is just made accessible post by post via codex functions when looping through all posts, and I can access the current post's data in my php code (or whatever page element I used)?
All the docs and tuts I found only throw some bits and pieces of info at you, but none I have found gives me the whole picture, like the complete basic Wordpress architecture with control and data flows.