Created
October 26, 2016 11:54
-
-
Save sareiodata/49b6a74c131c138ce9aa83a6fb53e4ac to your computer and use it in GitHub Desktop.
load a template for a particular URL
This file contains 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
// http://wordpress.stackexchange.com/questions/9870/how-do-you-create-a-virtual-page-in-wordpress | |
add_action( 'init', 'frugal_add_rewrite_rule' ); | |
function frugal_add_rewrite_rule() | |
{ | |
add_rewrite_rule( 'budget$', 'index.php?budget=1', 'top' ); | |
} | |
add_filter( 'query_vars', 'frugal_query_vars' ); | |
function frugal_query_vars( $query_vars ) | |
{ | |
$query_vars[] = 'budget'; | |
return $query_vars; | |
} | |
add_action( 'parse_request', 'frugal_parse_request' ); | |
function frugal_parse_request( &$wp ) | |
{ | |
if ( array_key_exists( 'budget', $wp->query_vars ) ) { | |
include 'budget-template.php'; | |
exit(); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment