Visiting permalinks page breaks add_rewrite_endpoint

by jimmyLi   Last Updated September 26, 2017 10:08 AM

I'm creating some endpoint rewritings on some templates, and if I flush the rewrite rules manually, everything works. But when I visit the permalinks page, even if I press save or just visit the page, the endpoints rewriting is not working, and I get 404.

If I manually flush the rewrite rules again, everything works.

add_action( 'init', 'generic_endpoint' );
function generic_endpoint() {
    add_rewrite_endpoint('Checkout', EP_ALL);
}

add_action( 'template_redirect', 'generic_template_redirect' );
function generic_template_redirect() {
    global $wp_query;
    if (isset($wp_query->query_vars['Checkout'])) { include dirname(__FILE__) . '/../_views/checkout.page.php'; exit; }
return;
}


Related Questions


Custom Permalink

Updated September 12, 2016 08:06 AM



posts not show after changing permalink

Updated June 27, 2015 13:03 PM