Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nielsenrc/7e3731f1e05cb89d970d to your computer and use it in GitHub Desktop.
Save nielsenrc/7e3731f1e05cb89d970d to your computer and use it in GitHub Desktop.
Wordpress | Create Virtual File in Wordpress Plugin
<?php
//assumes you have a locations.php file in your plugin folder
function advnap_kml() {
$url = str_replace( trailingslashit( site_url() ), '', plugins_url( '/locations.php', __FILE__ ) );
add_rewrite_rule( 'locations\\.kml$', $url, 'top' );
}
add_action( 'wp_loaded', 'advnap_kml' );
function advnap_plugin_activate() {
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'advnap_plugin_activate' );
//http://wordpress.stackexchange.com/questions/9870/how-do-you-create-a-virtual-page-in-wordpress
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment