$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>woocommerce offtopic - add_rewrite_rule() returns 404 page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

woocommerce offtopic - add_rewrite_rule() returns 404 page

matteradmin10PV0评论

I'm using add_rewrite_rule function to add this rule:

function custom_rewrite_rules() {

    add_rewrite_rule(
        'category/books/crime',
        'category/books/?filter_category=crime',
        'top'
    );

    flush_rewrite_rules();
}

add_action('init', 'custom_rewrite_rules');

But it only returns Error 404 Page not found.

When I use this kind of URL /?filter_category=crime the result is ok. But I would expect this URL return the same result because of added rewrite rule.

I'm also using WooCommerce plugin where "books" category and "category" attribute with "crime" term are created.

Is there something wrong in my function? If the function is good, where else could be the problem?

Post a comment

comment list (0)

  1. No comments so far