Rewrite API --重写规则API

2018-06-22 05:30:35来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

 

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 (钩子)

#这些钩子和动作的位置是 WP_Rewrite类 的  rewrite_rules()方法 


 

  • 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接口)

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Yii2使用驼峰命名的形式访问控制器

下一篇:php实现文件上传