I'm a newbie in WordPress. I wrote my custom theme. I have a problem with how to set up a home page and blog page.
So now I have created a blog page and set up a separate WordPress Blog Page for posts, and this is fine. I clicked on the menu "Post" and I'm directed to the post page.
But the problem is with the home menu. In index.php I have the following:
<?php get_header() ?>
<div>
<?php
while(have_posts()){ the_post();
get_template_part('content',''); // => this is my posts page
} ?>
</div>
<?php get_footer() ?>
When I come to the home page I see my page with style from content.php where I have all posts. Why index.php see my CSS style(from content.php) if I'm not on content.php. Also I created in admin-php home page with my custom text. WP sees this text, with CSS style from custom.php
CodePudding user response:
If you want to have a template that is used for your homepage you have to create a file named front-page.php
. You can read this Article in the Theme Developer Handbook for more information.