本文主要为大家详细介绍WordPress模板目录结构文件,为什么需要了解WordPress模板目录结构呢?虽然WordPress是利用WordPress模板建站的,但是WordPress模板不可能全部符合自己的心意,总有地方是需要我们亲自去修改的,了解了WordPress模板目录结构我们就可以对应着去修改了。This article mainly introduces the WordPress template directory structure file in detail. Why do you need to understand the WordPress template directory structure? Although WordPress uses WordPress templates to build a website, WordPress templates cannot all meet our own wishes. There are always places that we need to modify by ourselves. After understanding the WordPress template directory structure, we can modify it accordingly.

First of all, let’s take a look at the root directory file: the root directory idea is a file generated by the PHPstorm editor. It is not by default. This does not care about the background management folder. Generally, there is no need to operate the folders we will use frequently in the future, including themes, plug-ins, Language packs and media files The core files of this system, in principle, do not modify the contents of other PHP files under this folder. You need to know that index.php is the default entry file, and wp-config-sample.php is the configuration file. An example is a website. The configuration file contains database information, data table prefixes and other commonly used configuration information and other files.

Next, understand the structure under the wp-content folder: store language packs, store plug-ins, store themes, update folders, media inventory folders, pictures, attachments, etc., comes with a default homepage followed by themes folder: Each folder under the themes folder represents a WordPress theme template.

Next, we choose one of the topics to analyze the topic structure: The topic structure is used when the page to be visited is not found. This page is used to display, which is what we call the default archive page of the error page document, which is used to display the article list and comment template file. , The user displays the comment box and comment list theme common bottom file, the footer theme core function file, used to realize various functions, the theme common header file, and the popular point is the header theme picture display file, which is used to display the default home page file of the picture. System default file, when no other page file is found The default sidebar file of the display page. The default article content page. The default article style sheet file of the display page contains basic theme information. [Must have] The above is the directory structure of all WordPress templates. Style.css and index.php are necessary files for the theme. Need to be handled with care.

首先,我们来了解一下根目录文件:

WordPress根目录

idea是PHPstorm编辑器生成的文件,默认没有,这个不用管

wp-admin后台管理文件夹,一般情况无需操作

wp-content我们以后经常使用的文件夹,包含了主题、插件、语言包、媒体文件

wp-includes本系统的内核文件,原则上不修改该文件夹下面的内容

其他的PHP文件,需要知道index.php是默认的入口文件,wp-config-sample.php是配置文件示例

wp-confg.php是网站的配置文件,里面包含数据库信息,数据表前缀等各种常用配置信息

其他文件,了解一下就行,几乎用不上。

接下来,了解wp-content文件夹下的结构:

languages,存储语言包

plugins,存放插件

themes,存放主题

upgrade,更新文件夹

uploads,媒体库存放文件夹,图片、附件等

index.php,自带默认首页

其次,是themes文件夹:themes文件夹下的每一个文件夹就代表一个WordPress主题模板。

接下来,我们选择其中一个主题来剖析下主题结构:

WordPress主题结构

404.php – 当找不到被访问的页面时使用该页面展示,也就是我们所谓的错误页面

archive.php – 文档默认归档页面,用于显示文章列表

comments.php – 评论模板文件,用户显示评论框和评论列表

footer.php – 主题公用底部文件,页脚

functions.php – 主题核心函数文件,用于实现各种功能

header.php – 主题公用头部文件,通俗点就是页眉

image.php – 主题图片展示文件,用于显示图片

index.php – 默认首页文件,系统默认文件,当找不到其他页面文件时默认也使用该文件展示【必须有】

page.php – 默认页面文件,用于展示页面

readme.txt – 一般不用,用于说明主题

screenshot.png – 主题封面图片,后台主题列表显示的封面

search.php – 默认搜索结果展示页面

sidebar.php – 默认侧边栏文件

single.php – 默认文章内容页展示页面

style.css – 默认文章样式表文件,包含主题基本信息【必须有】

以上就是所有的WordPress模板目录结构,其中style.css和index.php是主题必须的文件,需谨慎处理。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注