Create custom url which executes code (not render render a WordPress entity)?
You can achieve this with a rewrite rule, you just need to exit execution before the main query is run. First, add a query var that will get set by the rewrite rule: function wpd_query_vars( $query_vars ){ $query_vars[] = ‘my_var’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_query_vars’ ); Next, the rewrite rule: function wpd_rewrite_rule(){ add_rewrite_rule( ‘^my-url/?$’, … Read more