如何找到WordPress网页的代码文件?

huangapple go评论61阅读模式
英文:

How to find code file of a WordPress webpage?

问题

I want to add something on a page of my WordPress site that is in localhost, but I can't find the file of that page in the htdocs folder from Xampp. I need the PHP file of that page to edit.

I searched in the "my site" folder in htdocs using some lines of code I can see when I inspect the source code of the page with SearchMyFiles.exe but nothing was found.

英文:

I want to add something on a page of my WordPress site that is in localhost, but I can't find the file of that page in the htdocs folder from Xampp. I need the PHP file of that page to edit.

I searched in the "my site" folder in htdocs using some lines of code I can see when I inspect the source code of the page with SearchMyFiles.exe but nothing was found.

如何找到WordPress网页的代码文件?
如何找到WordPress网页的代码文件?
如何找到WordPress网页的代码文件?

答案1

得分: 2

你要找的内容可能存储在你的数据库的wp_posts表中。

在源代码中,你只会找到与你的主题/模板相关的文件和脚本。对于WordPress的“页面”,通常使用的标准模板是文件“page.php”

除非你的主题中有更具体的模板文件(例如,archive.php用于显示存档页面),WordPress将使用模板page.php来显示你站点的所有页面。

基本上,WordPress数据库通过将所有项目分成12个表(在数据库中)来存储你的页面和文章。

  • wp_usermeta:保存用户的元数据
  • wp_users:保存你站点上用户的数据,包括他们的密码和用户名
  • wp_termmeta:保存分类术语的元数据
  • wp_term_relationships:存储帖子分配到分类的关联,保存帖子和其他类型的贡献,也称为“术语”。
  • wp_term_taxonomy:保存wp_terms表中术语的分类
  • wp_terms:保存你站点的所有分类术语,如标签和分类
  • wp_commentmeta:保存你站点评论的所有元数据
  • wp_comments:保存你的帖子评论,包括时间和发布者的姓名
  • wp_postmeta:存储wp_posts的所有元数据,如自定义字段和编辑锁
  • wp_posts:存储你的网站的每个文件或内容,包括标题、文本内容、修改日期、创建日期、作者和发布状态摘要。
英文:

what you are looking for is probably stored in the wp_posts table of your database.

In the source code, you will only find files and scripts related to your Themes/template. For WordPress "pages", the standard template used is usually the file "page.php".

Unless there is a more specific template file in your theme (e.g. archive.php to display archive pages), WordPress will use the template page.php to display all the pages of your site.

Basically, WordPress database stores your pages and posts by dividing all the items into 12 tables (n the database).

  • wp_usermeta: saves metadata on your users
  • wp_users: saves the user’s data on your site, including their password and username
  • wp_termmeta: saves metadata on your taxonomy terms
  • wp_term_relationships: stores the posts assignment to categories,
    saving the post and other types of contributions, also known as
    “terms.”
  • wp_term_taxonomy: saves the taxonomy of wp_terms table’s term
  • wp_terms: saves all your site’s taxonomy terms, such as the tags and
    categories
  • wp_commentmeta: saves all the metadata of your site’s comments
  • wp_comments: saves all your posts’ comments, which includes the time
    and the poster’s name
  • wp_postmeta: stores all the metadata from the wp_posts, like the
    custom fields and editing lock
  • wp_posts: stores every file or content of your website, including the
    title, text content, modification date, creation date,author,and the publishing status excerpt.

答案2

得分: 1

许多WordPress网站的页面不像HTML网站那样基于文件。您确定这个页面是基于文件还是基于某些数据库数值?如果不确定,可以随时提供URL。

英文:

Many of the pages in a WordPress website are not based on files unlike HTML sites. Are you sure that this page is based on a file or is it based on some database values? If you are unsure, then feel free to provide the URL.

答案3

得分: 1

WordPress有一个模板层次结构。以下是文档链接:https://developer.wordpress.org/themes/basics/template-hierarchy/

例如,对于主页,WordPress首先查找home.php。如果该文件不存在,它会转到index.php。

类似地:
首页显示:

  1. front-page.php
  2. home.php
  3. page.php
  4. index.php(如果以上三个文件都不存在,WordPress将使用index.php)

对于单篇文章:

  1. single-{post-type}-{slug}.php
  2. single-{post-type}.php
  3. single.php
  4. singular.php
  5. index.php

对于单页面:

  1. 自定义模板文件
  2. page-{slug}.php
  3. page-{id}.php
  4. page.php
  5. singular.php
  6. index.php

要确定您是在文章还是页面上,只需检查管理顶部栏(如果已登录)。您将在管理顶部栏中找到编辑文章或编辑页面按钮。

英文:

WordPress has a Template Hierarchy.
Here is the documentation: https://developer.wordpress.org/themes/basics/template-hierarchy/

E.x. For homepage, WordPress looks for home.php first. If the file is absent then it goes to index.php

Similarly:
Front Page display:

  1. front-page.php
  2. home.php
  3. page.php
  4. index.php (if none of the above 3 files are present, then WordPress follow index.php)

For Single Post:

  1. single-{post-type}-{slug}.php
  2. single-{post-type}.php
  3. single.php
  4. singular.php
  5. index.php

For Single Page:

  1. custom template file
  2. page-{slug}.php
  3. page-{id}.php
  4. page.php
  5. singular.php
  6. index.php

To find whether you are on post or page, just check the admin top bar (if you are logged in). You will find edit post or edit page button at the admin top bar.

huangapple
  • 本文由 发表于 2023年4月11日 02:11:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定