Skip to main content

Here’s a guide on how to create a basic WordPress theme from scratch:

  1. Create a new folder in the “wp-content/themes” directory of your WordPress installation with a unique name for your theme.
  2. Create the following files inside the new folder:
    • style.css: This file contains the styles for your theme.
    • index.php: This is the main template file that displays the content of your website.
    • functions.php: This file contains the functions and features you want to add to your theme.
  3. Add the following code to the style.css file:
/*
Theme Name: [Your Theme Name]
Author: [Your Name]
Description: [A brief description of your theme]
Version: 1.0
*/
  1. Add the following code to the index.php file:
<!DOCTYPE html>
<html>
<head>
    <?php wp_head(); ?>
</head>
<body>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <h1><?php the_title(); ?></h1>
        <?php the_content(); ?>
    <?php endwhile; endif; ?>
    <?php wp_footer(); ?>
</body>
</html>
  1. Add the following code to the functions.php file:
<?php
function [theme_name]_enqueue_styles() {
    wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', '[theme_name]_enqueue_styles' );

This is a basic WordPress theme structure. You can now activate your theme from the WordPress administration panel and start customizing it further.