WordPress Rewrite Rules Using Capture

I’m trying to make a rewrite rule for d3 visualizations that I’ll be keeping in my theme folder. Ultimately I want

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

to redirect to

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

However, I can’t get the capture rules to work. Here’s what I have so far:

    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');

Does anyone know why this doesn’t work?

Related posts

Leave a Reply

2 comments