Skip to content

Instantly share code, notes, and snippets.

@pedroelsner
Created July 9, 2012 02:52
Show Gist options
  • Save pedroelsner/3073937 to your computer and use it in GitHub Desktop.
Save pedroelsner/3073937 to your computer and use it in GitHub Desktop.
#6 - Rewrite WordPress
<?php
function my_template_redirect() {
global $wpdb;
global $wp_query;
global $current_user;
if ($wp_query->get('custom_page') == 'contato') {
// Definimos o título da página
add_filter('wp_title', create_function('$a', 'return "Contato «";'), 100);
if (file_exists(TEMPLATEPATH . '/tpl-contato.php')) {
include(TEMPLATEPATH . '/tpl-contato.php');
} else {
echo "Erro: Arquivo 'tpl-contato.php' não foi encontrado.";
}
exit();
}
}
add_action('template_redirect', 'my_template_redirect');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment