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/'; exit; }

Related Questions

Certain URLs 404 no matter what

Updated January 07, 2018 07:08 AM

Custom Permalink

Updated September 12, 2016 08:06 AM

make permalink go to a custom single.php file

Updated December 27, 2017 20:08 PM