How is the WordPress topic structure structured?

Source: Internet
Author: User
Tags closing tag

With powerful technologies, WordPress-based websites can be made into various forms. In addition to requiring WordPress theme developers to be proficient in HTML, PHP, JS, CSS, and other technologies, developers also need to master the WordPress topic framework. The following section describes how WordPress is structured with lizhi125.

Website appearance

A WordPress topic consists of a series of template files, each of which controls a part of the topic. No matter which page of the blog, the framework of the topic remains unchanged. This is the static part of the topic, which consists of the header. php, sidebar. php and footer. php file control. We can modify these files to check the pages we browse and display different contents, such as displaying different navigation on the posts page and page. However, we usually keep static parts consistent throughout the website.

The website exterior is controlled by the Code in the following four parts:

  • Header. php
    Display blog headers and navigation, including html code
  • The Loop
    The template file that displays The website theme content is called The Loop (which will be detailed later ).
  • Sidebar. php
    This file controls the sidebar. You can add controls to topics on multiple sidebar in functions. php.
  • Footer. php
    The end of the website and the html closing tag.
Page Composition

The WordPress basic page has a Homepage.(Index. php Control), Post page (Displays a complete blog, controlled by single. php), Independent page(Page. php Control), Archive(Archive. php)The following describes the code files that control these pages.

Index. php-home

The index file controls the appearance of the blog homepage. By default, the index file displays the latest blog through a loop, and a link to view the previous blog will be displayed at the bottom of the homepage.

Single. php-individual posts

This file is used to display the full text of a specific blog to be viewed by the reader.

Page. php-individual pages

This file controls the appearance of independent pages in the blog.

WordPress allows us to design different templates for different pages as follows:

1. Copy and rename page. php

2. Add the following code at the top of the file

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

Archive. php, category. php, tag. php-archives

We can also customize the appearance of an archives file. If there is no archive. php file, the archive is exactly the same as the home page; however, we can create an archive. php file to reconstruct the archive page. If you create a category. php file, the archiving page overwrites the file to show only directories. If you create a tag. php file, the archiving page overwrites the file to show only labels.

The Loop

Loop is probably the most powerful part of WordPress. It is the "loop query result ". In the loop body, we can output the title, Blog content, metadata, and comment of the selected Article in sequence. We can also use multiple loops in single page. For example, we can use one loop to display the full text of the blog, and the other loop to display the title and thumbnail of the relevant article.

The Loop structure is as follows:

  • Query post or page
  • Start Loop // Start the Loop
  • the_title(Outputs the title of the post) // title
  • the_excerpt(Outputs the post excerpt) // Abstract
  • the_content(Outputs the full post content) // content
  • the_category(Outputs the post categories) // directory
  • the_author(Outputs the post author) // prepared
  • the_date(Outputs the post date) // date
  • Other tags (there is a variety of other tags you can use in the loop) // tag
  • Endwhile; // end the loop
  • Exit the loop // Exit the loop
WordPress background files

To make theme work, WordPress also needs some necessary background files. These files can be modified based on individual needs. They can greatly change the appearance of the website or provide more powerful functions.

Comments. php

This file controls the comment output. If you want to provide the comment function on your blog, put it in the loop. The Comment. php file can be overwritten by plug-ins (such as Disqus)

Functions. php

Functions. php allows us to run custom code on WordPress to modify theme elements more freely.

Style.css

This is the main CSS file that controls the theme style. The top part of the file also contains the metadata of the topic, which is used to provide the topic name, author, and related links.

Graphic Analysis

The following is a powerful WordPress profiling Diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.