How to create own theme in WordPress.

This post illustrates the process of creating a custom wordpress theme based on the Bootstrap  theme.
We will start by downloading the Bootstrap theme through this link https://wordpress.org/themes/wp-bootstrap-starter/ .

These are the files in a theme and their use.

1. Two files required for a theme to run. The rest are optional.
a) index.php
b) style.css
2. The common file are
a) header.php :- It is for generating the site’s header section.
b) footer.php :- It is for generating the footer section.
c) sidebar.php :- It is for generating the sidebar section.
3. Some more files which are explain with its working
a) index.php :- The main template file.
b) style.css :- The main stylesheet, contains the information header and its will contain the style section.
c) rtl.css :- The right-to-left stylesheet is included automatically.
d) comments.php :- The comments template and it cointain the comment item.
e) front-page.php :- The front page template is always used as the site front page.
f) home.php :- The home page template is the front page by default.
g) header.php :- The header template file usually document type, meta information, links to stylesheets and scripts.
h) singular.php :- The singular template is used for posts when single.php is not found, or for pages when page.php are not found.
i) single.php :- The single post template is used when a visitor requests a single post.
j) single-{post-type}.php :- The single post template used when a visitor requests a single post from a custom post type.  For example, single-book.php would be        used for displaying single posts from a custom post type named book.  The index.php is used if a specific query template for the custom post type is not                present.
k) archive-{post-type}.php  :-  The archive post type template is used when visitors request a custom post type archive.  For example, archive-books.php would            be  used for displaying an archive of posts from the custom post type named books. The archive.php template file is used if the archive-{post-type}.php is              not present.
l) page.php :- The page template is used when visitors request individual pages, which are a built-in template.
m) page-{slug}.php :- The page slug template is used when visitors request a specific page, for example one with the “about” slug (page- about.php).
n) category.php :- The category template is used when visitors request posts by category.
o) tag.php :- The tag template is used when visitors request posts by tag.
p) taxonomy.php :- The taxonomy term template is used when a visitor requests a term in a custom taxonomy.
q) author.php :- The author page template is used whenever a visitor loads an author page.
r) date.php :- The date/time template is used when posts are requested by date or time.
s) archive.php :- The archive template is used when visitors request posts by category, author, or date.
t) search.php :- The search results template is used to display a visitor’s search results.
u) attachment.php :- The attachment template is used when viewing a single attachment like an image, pdf, or other media file.
v) image.php :- The image attachment template is a more specific version of attachment.php and is used when viewing a single image attachment.
w) 404.php :- The 404 template is used when WordPress cannot find a post, page, or other content that matches the visitor’s request.

To make your own page you have to write :-

<?php /* Template Name: fullpage */ ?>

To make your own post you have to write :-

 <?php
/*
* Template Name: Featured Article
* Template Post Type: post, page, product
*/

In the header section to add the menu section in your site then write this in header.php :-

<?php
wp_nav_menu(array(
'theme_location'    => 'primary',
'container'       => 'div',
'container_id'    => 'main-nav',
'container_class' => 'collapse navbar-collapse justify-content-end',
'menu_id'         => false,
'menu_class'      => 'navbar-nav',
'depth'           => 3,
'fallback_cb'     => 'wp_bootstrap_navwalker::fallback',
'walker'          => new wp_bootstrap_navwalker()
));
?>

Leave a Reply