1. 云栖社区>
  2. PHP教程>
  3. 正文

Rewrite API

作者:用户 来源:互联网 时间:2017-11-30 12:06:45

apirewrite

Rewrite API - 摘要: 本文讲的是Rewrite API, 原文地址:https://codex.wordpress.org/Rewrite_API Rewrite API(重写规则API) Description(描述)   WordPress allows theme and plugin

原文地址:https://codex.wordpress.org/Rewrite_API

Rewrite API(重写规则API)

Description(描述)


 

WordPress allows theme and plugin developers to programmatically specify new, custom rewrite rules. The following functions (which are mostly aliases for WP_Rewrite methods) can be used to achieve this.

WordPress允许主题和插件开发人员以编程方式指定新的自定义重写规则。以下功能(主要为wp_rewrite方法的别名)可以用来实现这。

Note that these rules are usually called inside the init hook. Furthermore, permalinks will need to be refreshed (you can do this from your admin under (Settings > Permalinks) before the rewrite changes will take effect. Requires one-time use of flush_rules() to take effect. See also Flushing Rewrite on Activation.

注意,这些规则通常在init钩子内部调用。此外,永久链接将需要刷新(你可以从你的管理下(设置> 固定链接)重写之前,修改将生效。。要求一次性使用flush_rules()生效。参见关于激活的刷新重写

API Reference(API引用)

Articles(文章


 

  • Lesson: Rewrite API Overview
  • Class: WP_Rewrite() - An overview of WordPress's built-in URL rewrite class.
  • 课程:重写API概述
  • Class: WP_Rewrite() - WordPress内置的URL重写类概述。

Hooks (钩子)


  • Filter: root_rewrite_rules - Filters the rewrite rules generated for the root of your weblog.
  • Filter: post_rewrite_rules - Filters the rewrite rules generated for permalink URLs.
  • Filter: page_rewrite_rules - Filters the rewrite rules generated for your Pages.
  • Filter: date_rewrite_rules - Filters the rewrite rules generated for dated archive URLs.
  • Filter: search_rewrite_rules - Filters the rewrite rules generated for search URLs.
  • Filter: comments_rewrite_rules - Filters the rewrite rules generated for the latest comment feed URLs.
  • Filter: author_rewrite_rules - Filters the rewrite rules generated for author archive URLs.
  • Filter: rewrite_rules_array - Filters all the rewrite rules at once.
  • Filter: {$permastruct}_rewrite_rules - Can be used to create or modify rewrite rules for any custom permastructs, such as taxonomies or custom post types.
  • Action: generate_rewrite_rules - Runs after all the rules have been created.
  • Filter: root_rewrite_rules - 过滤器,为你的博客的根生成的重写规则。(博客根)
  • Filter:post_rewrite_rules - Filters,为永久链接的URL生成的重写规则. (文章)
  • Filter: page_rewrite_rules - Filters,为页面生成的重写规则. (页面)
  • Filter: date_rewrite_rules - Filters,为过时的归档URL生成的重写规则. (日期归档)
  • Filter: search_rewrite_rules - Filters,为搜索URL生成的重写规则. (搜索页)
  • Filter: comments_rewrite_rules - Filters,为最新评论订阅 URL生成的重写规则. (评论订阅)
  • Filter: author_rewrite_rules - Filters,为作者归档URL生成的重写规则. (作者归档)
  • Filter: rewrite_rules_array - Filters,此刻的所有重写规则. (所有的重写规则)
  • Filter: {$permastruct}_rewrite_rules - 可用于创建或修改任何自定义固定链接重写规则,如分类自定义文章类型.
  • Action: generate_rewrite_rules -在创建了所有规则之后运行. (after

Functions(函数)


  • add_rewrite_tag() - Can be used to allow WordPress to recognize custom variables (particularly custom querystring variables).
  • add_rewrite_rule() - Allows you to specify new, custom rewrite rules.
  • add_rewrite_endpoint() - Add a new endpoint like /trackback/
  • flush_rules() - Regenerate the rewrite rules and save them to the database.
  • flush_rewrite_rules() - Remove rewrite rules and then recreate rewrite rules.
  • generate_rewrite_rules() - Generates rewrite rules from a permalink structure
  • add_permastruct() - Add a new permastruct
  • add_feed()- Add a new feed type like /atom1/
  • add_rewrite_tag() - 可用于允许WordPress识别自定义变量(特别是自定义查询字符串变量.
  • add_rewrite_rule() - 允许您指定新的,自定义的重写规则.
  • add_rewrite_endpoint() - 添加一个新的端点,例如 /trackback/
  • flush_rules() - 重新生成重写规则并保存到数据库中.
  • flush_rewrite_rules() - 移除重写规则,然后重新创建重写规则.
  • generate_rewrite_rules() - 根据 固定链接结构 生成 重写规则
  • add_permastruct() - 添加一个新的 固定链接结构
  • add_feed()- 添加一个新的订阅类型, 例如 /atom1/

      Categories(分类):

  • Advanced Topics (高级主题)
  • WordPress Development (WordPress 开发)
  • API (API接口)

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索api rewrite ,以便于您获取更多的相关知识。