I am pretty new to WordPress and I am trying to make a basic custom theme from scratch. The basic navigation menu is displayed and works on all of my pages except for the default blog page (which just appears as a blank white screen when clicked on). I have my theme split up into multiple files (header, footer, page, archives, etc). I think that the page.php file is what is supposed to display the blog, but it only works on the home, about, and test pages.
page.php:
<?php get header();?>
<div>
<h1><?php the_title();?></h1>
<?php if (have_posts()) : while(have_posts()) : the_post();?>
<?php the_content();?>
<?php endwhile; endif;?>
</div>
<?php get_footer();?>
post.php
is not for the post type post
it is for static pages or custom post-types.
You are looking for single.php
or index.php
.
This template Hierarchy from the Wordpress docs will help you.
Also see: https://developer.wordpress.org/themes/basics/template-hierarchy/
Style.css
Go to the WordPress default theme folder, open the style.css file. Copy the commented code at the top and paste it to the GlossyBlue style.css file. Change the theme name and the author information as you desire.
Splitting The Files
Now you need to understand where to split the file into several files: header.php, sidebar.php, and footer.php. The image below shows a simplified version of my index file and how the markups should split.
Header.php
Open the index.html file. Cut from the top to where the ends, paste it in a new PHP file, and save the file as header.php.
Sidebar.php
Back to the index.html file, cut from where the start to the closing tag of and paste it in a new PHP file, save it as sidebar.php.
Footer.php
Back to the index.html file, cut from the tag to the end of and paste it in a new PHP file, save it as footer.php.
Index.php
Now in your index.html file, you should only have the wrap. Save the file as index.php. Insert the line:get_header, get_sidebar, and get_footer in the same order as your layout structure.
Single.php
Now, it is time to do the single.php template. If you want, you can go through the same process — cut & paste from the default theme. But, I find it easier to use the index.php that you just created and save it as single.php. Open the default theme single.php file and copy the Template Tags over. Then include the comments_template. The image below highlights what I've changed:
Page.php
With the single.php template you just created, save it as page.php. Remove the post date, comment form, next/previous link… and that's it.. there goes your page.php template.
Detailed document here : http://webdesignerwall.com/tutorials/building-custom-wordpress-theme
You question answer :
Copy page.php and rename it to single.php file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.