Created
September 9, 2015 20:10
-
-
Save nielsenrc/7e3731f1e05cb89d970d to your computer and use it in GitHub Desktop.
Wordpress | Create Virtual File in Wordpress Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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