Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Last active December 15, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fdaciuk/5281457 to your computer and use it in GitHub Desktop.
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
<?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();
}
<?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