Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Last active Dec 15, 2015
Embed
What would you like to do?
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