Last active
December 15, 2015 15:19
-
-
Save fdaciuk/5281457 to your computer and use it in GitHub Desktop.
Criando páginas institucionais no WordPress em precisar criar a página pelo painel
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
<?php | |
$pages = array( 'sobre', 'contato' ); | |
// Verificar se a URL acessada consta no array. | |
if( in_array( get_query_var( 'pagename' ), $pages ) ) { | |
header( 'HTTP/1.1 200 OK' ); | |
get_template_part( 'page-' . get_query_var( 'pagename' ) ); | |
die(); | |
} else { | |
header( 'Location: ' . home_url() ); | |
die(); | |
} |
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
<?php | |
// Esse código vai no functions.php do seu tema | |
if( ! is_admin() ) { | |
function add_class( $classes ) { | |
if( is_home() || is_front_page() ) { | |
$classes[] = 'page-home'; | |
} elseif( is_404() ) { | |
$classes = array(); | |
$classes[] = 'page-' . get_query_var( 'pagename' ); | |
} | |
return $classes; | |
} | |
// Filtro para adicionar classes no gancho body_class | |
add_filter( 'body_class', 'add_class' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment