Skip to content

Instantly share code, notes, and snippets.

@dexfs
Created May 28, 2013 20:34
Show Gist options
  • Save dexfs/5665899 to your computer and use it in GitHub Desktop.
Save dexfs/5665899 to your computer and use it in GitHub Desktop.
<?php
function rewrite_form_envio_cupula_dos_povos($wp_rewrite) {
$new_rules = array(
"cupula-dos-povos/form-envio" => 'index.php?meu_template=form_envio_cupula_dos_povos',
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'rewrite_form_envio_cupula_dos_povos');
function registrar_query_vars($public_query_vars) {
$public_query_vars[] = "meu_template";
return $public_query_vars;
}
add_filter('query_vars', 'registrar_query_vars');
function template_redirect_intercept(){
global $wp_query;
// verifica a variável
if ( $wp_query->get('meu_template') == 'form_envio_cupula_dos_povos' ) {
// se tiver o valor que queremos, usa o nosso template
if (file_exists( TEMPLATEPATH . '/form_envio_cupula_dos_povos.php' )) {
include( TEMPLATEPATH . '/form_envio_cupula_dos_povos.php' );
exit;
}
}
}
add_action('template_redirect', 'template_redirect_intercept');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment