The "internal" rewrite rule above will route traffic through index.php using the pagename argument (which necessitates having a page with slug invite).

I want to direct routing to invite.php (which will render an ICS calendar file and force download).

I looked into the below implementation, however, this appears to directly modify .htaccess file. My site is using nginx so this won't work.

  • This answer might help you. – Milo Sep 28 '17 at 15:59
  • Thanks. That answer run a new WP_Query under their specific conditions. In my case, I am diverting to a file that has non-WP logic, not tied to any post type etc. My invite.php sets a Content-Disposition: attachment; filename=invite.ics header to force a download and echo's a var (which becomes the downloaded files content) – Allan Thomas Sep 28 '17 at 16:15
  • The contents of that if condition are irrelevant to the answer, just remove that code and put your own logic inside. – Milo Sep 28 '17 at 16:19
  • Right. The logic I need within parse_query to use invite.php isn't clear to me. Thanks for the answer but it doesn't really solve the issue – Allan Thomas Sep 28 '17 at 16:23
  • 1
    or just remove invite.php entirely and put whatever code is in that file within the function instead. – Milo Sep 28 '17 at 16:26
add_action('parse_query', function(&$wp_query) {

    if (array_key_exists('iid', $wp_query->query_vars) && $wp_query->query['pagename'] === 'invite') {

        $iid = get_query_var('iid');

        // Do some stuff




| improve this answer | |
  • 1
    what is that? a blob of code by itself is not an answer – Mark Kaplun Sep 28 '17 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.