原文地址:https://codex.wordpress.org/Rewrite_API Rewrite API(重寫規則API) Description(描述) WordPress allows theme and plugin developers to programmatically spe ...
原文地址: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介面)