I want to create an archive endpoint page that will have a dynamic slug, based on the taxonomy term slug.
e.g. If the taxonomy is Food and the current term is Onion, I want the endpoint slug to look like onion-recipes
.
www.domain.com/food/onion/onion-recipes
Gives me a 404
even after flushing permalinks.
Code:
add_action( 'init', function() {
$term = get_queried_object();
$ep_slug = $term->slug.'-recipes';
add_rewrite_endpoint( $ep_slug, EP_PAGES );
} );