|
Arquivos basicos para a criação de um theme |
|
- functions.php |
|
- index.php |
|
- header.php |
|
- footer.php |
|
- style.css |
|
- screenshot.png |
|
- opcional |
|
- tambem é possivel criar modelos de pagina para isso criar um arquivo exemplo: pagina-interna.php |
|
|
|
<!-- CONTEUDO: footer.php (antes do fechamento do body) --> |
|
<?php wp_footer(); ?> |
|
</body> |
|
|
|
<!-- CONTEUDO: pagina-interna.php --> |
|
<?php |
|
/* |
|
Template Name: [nome do template] |
|
*/ |
|
|
|
get_header(); |
|
|
|
// conteudo do da pagina |
|
|
|
get_footer(); |
|
?> |
|
|
|
<!-- CONTEUDO: style.css --> |
|
/* |
|
Theme Name: [nome do tema] |
|
Theme URI: [site do tema] |
|
Author: [nome do autor] |
|
Author URI: [site o autor] |
|
Description: [descricao do tema] |
|
Version: [versao do thema] |
|
*/ |
|
|
|
|
|
<!-- html dinamico --> |
|
<html <?php language_attributes(); ?>> |
|
<!-- charset dinamico --> |
|
<meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
<!-- titulo da pagina --> |
|
<title> |
|
<?php |
|
if (is_home()) { |
|
echo bloginfo() . " | " . get_bloginfo('description'); |
|
} else { |
|
wp_title('|', true, 'right'); |
|
bloginfo(); |
|
} |
|
?> |
|
</title> |
|
<link rel="profile" href="http://gmpg.org/xfn/11"> |
|
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> |
|
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> |
|
|
|
<!-- antes de fechar o head --> |
|
<?php wp_head(); ?> |
|
</head> |
|
|
|
<!-- body class --> |
|
<body <?php body_class(); ?>> |
|
|
|
<?php |
|
|
|
############################################################### |
|
## Retirando a metatag WordPress Generator |
|
############################################################### |
|
remove_action('wp_head', 'wp_generator'); |
|
|
|
############################################################### |
|
# ALGUMAS CONFIGURAÇÔES |
|
############################################################### |
|
|
|
|
|
############################################################### |
|
# URLs |
|
############################################################### |
|
// url home |
|
echo esc_url( home_url( '/' ) ); |
|
// url completa da raiz do template |
|
echo get_template_directory_uri(); |
|
|
|
############################################################### |
|
# Adiciona menus personalizados para ser utilizado no template |
|
############################################################### |
|
// no arquivo function.php |
|
add_action('init', 'register_my_menus'); |
|
|
|
function register_my_menus() { |
|
register_nav_menus( |
|
array( |
|
'menu-topo' => __('Menu Topo'), |
|
'menu-coluna-lateral' => __('Menu Coluna Lateral'), |
|
'menu-rodape' => __('Menu Rodapé') |
|
) |
|
); |
|
} |
|
|
|
// local onde deseja ativar o menu no template |
|
// Codex: https://codex.wordpress.org/Function_Reference/wp_nav_menu |
|
wp_nav_menu( |
|
array( |
|
'theme_location' => 'menu-topo', |
|
'items_wrap' => '<ul class="nav navbar-nav navbar-right">%3$s</ul>' |
|
) |
|
); |
|
|
|
############################################################### |
|
# Adicionando suporte a imagens destacadas no template |
|
############################################################### |
|
add_theme_support('post-thumbnails'); |
|
|
|
############################################################### |
|
# Suporte ao menu ativo |
|
############################################################### |
|
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); |
|
|
|
function special_nav_class ($classes, $item) { |
|
if (in_array('current-menu-item', $classes) ){ |
|
$classes[] = 'active '; |
|
} |
|
return $classes; |
|
} |
|
|
|
############################################################### |
|
# Tamanho de miniatura personaliza |
|
############################################################### |
|
add_action( 'after_setup_theme', 'thumb_medio' ); |
|
function thumb_medio(){ |
|
add_image_size( 'thumb_medio', 570, 311, true ); |
|
} |