簡體   English   中英

使用Capture的Wordpress重寫規則

[英]Wordpress Rewrite Rules Using Capture

我正在嘗試為將保留在主題文件夾中的d3可視化制定重寫規則。 最終我想要

    d3/[some-year]/[some-string]

重定向到

    wp-content/themes/my-theme/d3-library/[some-year]/[some-string]/index.html

但是,我無法使捕獲規則起作用。 這是我到目前為止的內容:

    function d3_rewrite() {
        add_rewrite_rule(
            'wp-content/themes/d3/(20[0-9][0-9]/.*)',
            'wp-content/themes/my-theme/assets/d3-library/$match[1]/index.html',
            'top'
        );
    }
    add_action('init', 'd3_rewrite');

有誰知道為什么這不起作用?

使用wp-content/themes/my-theme/assets/d3-library/$1/index.html 問題出在替換后向引用中。

如果您有$match[1] ,那不應該是$matches[1]嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM