Hello all! I am going to create my own WordPress Theme from scratch starting from today. Actually, I am going to go through all WordPress Theme Development Handbook and create one theme.
So, today is the day one.
In WordPress Theme Development Handbook is mentioned that there are only two files absolutely required in a WordPress theme:
index.php
and
style.css
So, I am going to create them now.
File index.php
The simplest index.php file can contain next code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content(); endwhile; else : _e( 'Sorry, no posts matched your criteria.', 'scratchok' ); endif; ?> </body> </html>
In reality this code will be more complicated. But for now it should work.
File style.css
The next file style.css should contain at least one multi-line comment with special fields like this:
/* Theme Name: scratchok Theme URI: https://positiveknight.com/ Author: wpok13 Author URI: https://positiveknight.com/ Description: Theme created from scratch for online tutorial. Tags: blog, custom Version: 1.0 Requires at least: 5.0 Tested up to: 5.4 Requires PHP: 7.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: scratchok */
Code here: https://github.com/wpok13/scratchok