How to create Custom wordpress theme from scratch
Step 1: Create a folder to hold your theme files.
If we are going to be building themes, we need to know where the files that make up a WordPress theme live in a WordPress Installation. This is pretty easy. We know that a WordPress installation typically has a root directory named wordpress
. Here is what our root directory looks like in PHP extention
File Path:
Wordpress Folder >> wp-content >> Themes >> Create folder Example my-theme
Step 2: Create Files in your custom theme folder
index.php
sidebar.php
header.php
footer.php
functions.php
frontpage.php
single.php
style.css
Step 3: Style.css File
/*
Theme Name: mytheme
Author: digigrowth
Author URI: https://digigrowthsolution.blogspot.com
Version: 1.0
*/
This information shows in your Wordpress dashboard theme details section
Step 4: index.php File
<? php get_header(); ?>
this code will connect your header file to your index page
<h1>Custom Theme!</h1>
.Other Designs Layout for your page
use <?php get_footer() ?> at the last of the page to connect footer on the page
Step 5: Header.php File
Type here your Header Section like
<html>
<head>
<title>My Theme</title>
</head>
<body>
<header>
<nav>
</nav>
Step 6: Footer.php File
Type here your Footer Code like:
<footer>
my footer
</footer>
</body>
</html>
Step 5: Functions.php File
This file is used for Connect Stylesheet, Javascripts, And create Function for other works like dynamic menu etc
Use Enquee To connect with Js and Css File
<?php
function custom_theme_assets() {
wp_enqueue_style( 'style', get_stylesheet_uri()."/style.css" );
}
add_action( 'wp_enqueue_scripts', 'custom_theme_assets' );
Use wp_enqueue_script at place of wp_enqueue_syle to imports js
Your Basic Theme Structure is ready to use Further we will Describe in next post
Comments
Post a Comment