2: The files you need in WordPress and their role

 

WordPress Files

Method 1

Step 1 : Download this folder containing the basic files 
Step 2 : Open http://localhost/wordpress/wp-admin/  
Step 3 : Go to Appearance and Themes , click Add new after that click Upload Theme 


Step 4 :  Upload your folder | WordPress 





File names and their functions

index.php

Index PHP refers to a PHP file, named Index.php in this case.

Index.php is commonly placed in a cPanel Website’s Root folder. This file is responsible to show the home page of a website.

As its name suggests, it is commonly coded in PHP language.

When the Home page of a web application is called, the web server tries to find and process Index.php in the first attempt.

The later scene is based on Index PHP file. In this case, if the Index.php file is correctly setup, the visitors’ see the home page of the website.

Developers can also handle users’ requests with Index.php file, such as renaming or changing code in Index.php directly affects users’ expectations.

So, let’s discuss, what should we put inside Index.php file.

It depends on several factors. For example, if you are coding a custom web application, you will most likely code Index.php manually, depending on how you want your home page display.

Similarly, on the other hand – if you have built your website with a Content Management System like WordPress, you can certainly ignore Index.php file.

Because CMS automatically creates and setup Index.php file during the setup process.

However, if you do want to know the default content of a sample Index.php file, you can examine the source code HERE.

Please note, there are no strict rules regarding Index PHP file content. It depends on personal preferences, custom applications, and CMS used for a website.

Normally, an Index.php file includes code to process a site’s Header, Footer, and a basic view of Body content. For example, if there are posts in the site, the home page will be populated with Blog Posts.

If nothing is found, a message will be shown That no posts we found.

In other words, it is not necessary to name the home page as Index.php file. Normally, Index.HTML is being used to address a site’s home page.

However, if you are using PHP, you would most likely use Index.php as a file responsible for your site’s home page.

In case of users’ requests for specific pages, PHP is responsible to process users’ requests depending on page types, such as home page, Category page, or a 404 page.

In case of a home page, the content of Index.php is processed to show the site’s home page to the user.

Also, keep in mind That different CMS(s) handle index.php in a different way.

For example, when a user requests the home page of a WordPress website, the web server looks for index.html file.

If not found, the custom application would most likely execute index.php after failing to find other variations of a home page Template like Index.HTML. 

header.php

It's important for you to know what exactly the header.php file should contain in a WordPress theme.

We have more than a logo and menu in this file—we also have the head tag and lots of other tags, like link, script, meta, and title.

Remember that the header of your site is the content which is shown on all the pages of your site. For example, the logo and menu are shown on all the pages of your site, and thus, they should be included in the header.php file.

If an element is shown only on a specific page, then you should not include it the header.php file.

functions.php

The functions.php has the role of simplifying the development process of a website. It is a fundamental resource to ensure that your WordPress hosting serves the purposes you want. 

Functions.php can be called from any part of the code to perform a task and return some kind of value. The action can be executed as many times as you want. 

As described in The WordPress Codex, you can use this feature to call PHP functions and built-in WordPress, defining your own settings and enabling certain features such as post thumbnails and navigation menus. 

The php functions also open the way for you to use WordPress hooks, which allow one piece of code to interact/modify another piece of code at specific, pre-defined spots. This way, you automate the process and avoid the need to rewrite code. 

Hooks can be defined in two categories: actions e filters:

an action takes the info it receives, acts on it, and returns nothing to the calling hook.
a filter takes the info it receives, filters it, and returns it for further use.
Your code may contain one or more functions, and when it calls a function, it will wait for it to return a value. When this value is returned, or all processes of this function are finished, your code will continue its operation. 

single.php

Sometimes you may want a different look and feel for certain posts on your WordPress website. For instance, you may want to use a different layout for featured articles or stories in a particular category.

This is where you need a custom single post template in WordPress.

By default, WordPress uses the single post template based on the WordPress template hierarchy. All themes come with a single.php template, and this is used by default for all of your single posts.

Some themes may also include additional templates or layout choices that you can use.

It is very much like creating a custom page template. Most WordPress themes also come with page templates that you can use while editing a post or page in WordPress.

archive.php 

Unless a developer includes meta data with permalinks in their templates, the archive.php will not be used. Meta data is information tied to the post. For example, the date something was posted on, the author, and any categories, tags, or taxonomies used for the post are all examples of meta data. When a visitor to a website clicks on the meta data, the archive.php will render any posts associated with that piece of meta data. For example, if a visitor clicks on the name of an author, the archive.php will display all posts by that author.

Commonly, the title of the page being displayed by archive.php will be the name of the meta data the user clicked on. So, if the user clicked on the Author’s name, the page name displaying all the other author’s posts will be the Author’s name and frequently there might be an additional description about the meta data. Here is a code example from Twenty Fifteen on their archive.php file. This snippet is the only piece of code that makes the archive.php file different from a home.php or index.php file.

search.php 

In this file you can customize the search results page of the user
Examples of articles, photos, authors ...

This code snippet pulls in the query that was searched with get_search_query(). Often search.php will only pull in the excerpt instead of the full content since the user is trying to determine if the article or page fits their search.

mostly using in search articles.

author.php

If you are building a theme designed for multiple authors, it might make sense to build an author.php template. In the author.php template you could provide more information about an author, their gravatar, pull in their social media sites, and then all posts written by them. This would be a step up from relying just on the archive.php file.

Additionally, you can build specific author.php files for individual author’s by using their author ID or nicename. For example, say John Doe is the head author for a site with many guest authors. You may want all the guest authors’ information to display with author.php but you might build a specific author page with more information for John Doe by creating author-johndoe.php or author-3.php if his author ID is 3.

404.php

This can immediately frustrate your visitors. Also, when facing this error, their only choice is to hit the back button or go back to Google and search again. This will increase the bounce rate and affect your site SEO.

and you can customize your 404 page in 404.php file

That’s why you should customize your 404 pages by adding a few more helpful links and possibly a little humor. Accordingly, your visitors will easily know where and how to access the right place.

comments.php

WordPress displays comments in your theme based on the settings and code in the comments.php file within your WordPress theme.

The comments.php template contains all the logic needed to pull comments out of the database and display them in your theme.

Before we explore the template file you’ll want to know how to pull in the partial template file on the appropriate pages such as single.php. You’ll wrap the comment template tag in a conditional statement so comments.php is only pulled in if it makes sense to do.

searchform.php

this file using for customizing search bar with CSS language.

footer.php

The footer in WordPress is the bottom part of your website that appears after the main content area. It’s generally on every page of your WordPress website.

Many beginners overlook this area, but there are several ways you can make it more helpful for your visitors. You can even use your footer to boost your WordPress SEO and your business.

Here’s an example of our footer on WPBeginner that millions of readers see every month.

All top WordPress themes come with a footer widget area that’s easy to edit. You can improve this area by adding widgets, removing links, adding code, and even creating fully custom footers for different pages.

That being said, let’s take a look at how to easily edit the footer in WordPress. You can use the following links to jump to the section you want to read.


If you have any questions write in the comment / Share this article to be programmers

Welcome! My name is Saad, I'm web developer, graphic designer and UI/UX designer. I love creating fun things.

1 comment

  1. If you have any questions write in the comment / Share this article to be programmers
© Wird Dev. All rights reserved. Developed by Jago Desain