Understanding WordPress theme files and underscores

1) Why when I’m adressing mysite.com/index.php I see the text I’ve entered while creating the page, but there’s no code for that in the index.php file?

You’ve assigned page1 as your Front Page so this displays instead of the index.php. You will need to create a page template:

https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

if you want to edit the code for the page. Alternatively, you can use shortcodes to add to the content part of the page.

2)Why the single_post_title() function doesn’t return something?

Again, probably because you’re not looking at index.php, also it’s not in the loop, but I guess it probably doesn’t need to be.

3) Where’s the post navigation? There’s code for that in the index.php file

Again this is because you’re not actually seeing index.php being rendered when looking at page1.

4) Are the posts page and the home page are the same pages?

Not really, you can set your own homepage to a page and create a unique page template for it, just like you can for post pages. If you don’t set a front page though, it defaults to index.php

5) How does the index.php file work? It controls the front page and the post page (and maybe some more pages) at the same time? I don’t get it.

Think I’ve kind of answered that above!!

Basically you need to create a page template, copy and paste the contents of index.php into it, set that page template on your Page when logged into your admin area, and then any changes you make to page template will show on the home page.

In the root of your site create a folder called: page-templates

Inside this folder create a page template, for example: home-template.php

In here, at the very top put this:

<?php
/**
* Template Name: Home Template
*/
?>

After that, paste the contents of your index.php, save and upload the file etc.

Then log in, head to the edit page screen for the one you’re setting as the front page, on the right hand side there should be a select box with page template options:

Set template

Publish the page, and you’re done!